###### 有骨气的牛马侠

2021-01-13 17:28 阅读 9

# 杭电oj 2023 ，这段代码为什么wa？

``````#include<iostream>
#include<iomanip>
using namespace std;
int a[50][5];
float b[50], c[5];
int main()
{
int n, m, sum;
while (cin >> n >> m)
{
for (int i = 0; i < n; i++)
{
sum = 0;
for (int j = 0; j < m; j++)
{
cin >> a[i][j];
sum += a[i][j];
}
b[i] = float(sum) /float(m);
}
for (int i = 0; i < m; i++)
{
sum = 0;
for (int j = 0; j < n; j++)
{
sum += a[j][i];
}
c[i] = float(sum) / float(n);
}
for (int i = 0; i < n; i++)
{
if(i==n-1)
{
cout <<fixed<<setprecision(2)<< b[i] << endl; break;
}
else
{
cout << fixed << setprecision(2) << b[i] << " ";
}
}
for (int i = 0; i < m; i++)
{
if(i==m-1)
{
cout << fixed << setprecision(2) << c[i] << endl; break;
}
else
{
cout << fixed << setprecision(2) << c[i] << " ";
}
}
int sum1 = 0;
for (int i = 0; i < n ; i++)
{
int t = 0;
for (int j = 0; j < m; j++)
{
if(a[i][j]<c[j])
{
t++;
}
}
if(t==0)
{
sum1++;
}
}
cout << sum1 << endl << endl;
}
return 0;
}``````
• 点赞
• 收藏
• 复制链接分享

#### 1条回答默认 最新

• 已采纳
qq_25376897 2021-01-13 17:59

难道是要换成double ？

点赞 评论 复制链接分享