#include<stdio.h>
int main(void)
{
int m[5][5];
int min, max;
for (int i = 0; i < 5; i++)
{
printf("Please enter %d student's grade for five courses:", i + 1);
for (int j = 0; j < 5; j++)
{
scanf_s("%d", &m[i][j]);
printf("\n");
}
}
printf("\n");
for (int i = 0, sum = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
sum += m[i][j];
}
printf("%d student total grade:%d\n", i + 1, sum);
printf("%d student average grade:%.2f\n", i + 1, sum / 5.0);
sum = 0;
}
printf("\n");
for (int i = 0, sum = 0; i < 5; i++)
{
min = m[0][i];
max = m[0][i];
for (int j = 0; j < 5; j++)
{
sum += m[j][i];
if (m[j][i] <= min)
{
min = m[j][i];
}
if (m[j][i] >= max)
{
max = m[j][i];
}
}
printf("%d course average grade:%f\n", i + 1, sum / 5.0);
printf("max:%d\n", max);
printf("min:%d\n", min);
sum = 0;
}
return 0;
}
8---8
最新推荐文章于 2024-09-09 10:24:53 发布