求平均成绩(hdu2023)-LMLPHP

注意:要心细,不要错在小细节上。如int c[6];double agve; c[j]=agve;这是错误的。

#include<stdio.h>
#include<cmath>
int a[][];
double c[];
int main()
{
int n;
int m;
char d;
while (scanf_s("%d%d%c", &n, &m, &d) != EOF)
{
for (int i = ; i<n; i++)
{
for (int j = ; j<m; j++)
{
int b;
scanf_s("%d", &b);
a[i][j] = b;
}
}
for (int i = ; i<n; i++)
{
double sum = ;
double avge;
for (int j = ; j<m; j++)
{
sum = sum + a[i][j];
}
avge = sum*1.0 / m;
printf("%0.2lf", avge);
if (i<n - )
printf(" ");
}
printf("\n");
for (int j = ; j<m; j++)
{
double sum = ;
double avge;
for (int i = ; i<n; i++)
{
sum = sum + a[i][j];
}
avge = sum*1.0 / n;
c[j] = avge;
printf("%0.2lf", avge);
if (j<m - )
printf(" ");
}
printf("\n");
int count = ;
for (int i = ; i<n; i++)
{
int count1 = ;
for (int j = ; j<m; j++)
{
if (a[i][j] >= c[j])
count1++;
}
if (count1 == m)
count++;
}
printf("%d\n\n", count);
}
}
05-19 03:25