杭电ACM2023题,求高手指出我的错误!运行结果对但是不AC 5
#include<iostream>#include<iomanip>usingnamespacestd;intmain(){intn,m,cour[50][5],cou...
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n, m,cour[50][5],count=0,count1=0;
float ave_Stud[50], ave_Cour[5];
while (cin >> n >> m)
{
for (int i = 0;i < n;i++)
{
for (int j = 0;j < m;j++)
{
cin >> cour[i][j];
count = count + cour[i][j];
}
ave_Stud[i] = (float)count / m;
count = 0;
}
for (int j = 0;j < m;j++)
{
for (int i = 0;i < n;i++)
count1 = count1 + cour[i][j];
ave_Cour[j] = (float)count1 / n;
count1 = 0;
}
for (int i = 0;i < n;i++)
cout << setiosflags(ios::fixed) << setprecision(2) << ave_Stud[i] << ' ';
cout << '\b'<<endl;
for (int j = 0;j < m;j++)
cout << setiosflags(ios::fixed) << setprecision(2) << ave_Cour[j] << ' ';
cout << '\b'<<endl;
int num1=0, num2=0;
for (int i = 0;i < n;i++)
{
for (int j = 0;j < m;j++)
if (cour[i][j] >= ave_Cour[j])num1 += 1;
if (num1 == m)num2 += 1;
num1 = 0;
}
cout << num2<<endl;
cout << endl;
}
return 0;
} 展开
#include <iomanip>
using namespace std;
int main()
{
int n, m,cour[50][5],count=0,count1=0;
float ave_Stud[50], ave_Cour[5];
while (cin >> n >> m)
{
for (int i = 0;i < n;i++)
{
for (int j = 0;j < m;j++)
{
cin >> cour[i][j];
count = count + cour[i][j];
}
ave_Stud[i] = (float)count / m;
count = 0;
}
for (int j = 0;j < m;j++)
{
for (int i = 0;i < n;i++)
count1 = count1 + cour[i][j];
ave_Cour[j] = (float)count1 / n;
count1 = 0;
}
for (int i = 0;i < n;i++)
cout << setiosflags(ios::fixed) << setprecision(2) << ave_Stud[i] << ' ';
cout << '\b'<<endl;
for (int j = 0;j < m;j++)
cout << setiosflags(ios::fixed) << setprecision(2) << ave_Cour[j] << ' ';
cout << '\b'<<endl;
int num1=0, num2=0;
for (int i = 0;i < n;i++)
{
for (int j = 0;j < m;j++)
if (cour[i][j] >= ave_Cour[j])num1 += 1;
if (num1 == m)num2 += 1;
num1 = 0;
}
cout << num2<<endl;
cout << endl;
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询