求平均成绩
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 103993 Accepted Submission(s): 24170
每个测试实例后面跟一个空行。
//#include<iostream>
//using namespace std;
#include<stdio.h>
int main()
{
int a[60][60];
double sum,ave1[60],ave2[60];
int i,j,n,m,p,count;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(i = 0;i < n;i++)
{
for(j = 0;j < m;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i = 0;i < n;i++)
{
sum = 0;
for(j = 0;j < m;j++)
{
sum += a[i][j];
}
ave1[i] = sum/m;
}
for(j = 0;j < m;j++)
{
sum = 0;
for(i = 0;i < n;i++)
{
sum += a[i][j];
}
ave2[j] = sum/n;
}
count = 0;
for(i = 0;i < n;i++)
{
p = 1;
for(j = 0;j < m;j++)
{
if(a[i][j] < ave2[j])
{
p = 0;
break;
}
}
if(p)
{
count++;
}
}
for(i = 0;i < n-1;i++)
{
printf("%.2lf ",ave1[i]);
}
printf("%.2lf
",ave1[i]);
for(j = 0;j < m-1;j++)
{
printf("%.2lf ",ave2[j]);
}
printf("%.2lf
",ave2[j]);
printf("%d
",count);
}
return 0;
}