#include<stdio.h>
float max = 0, min = 0;
float try1(float score[3][5], int a, int b)
{
int i, j;
float sum = 0, ave = 0;
max = 0;
min = 0;
//for(i = 0; i < b; i++)
for(i = 0; i < a; i++)
{
//for(j = 0; j < a; j++)
for(j = 0; j < b; j++)
{
sum += score[i][j];
ave = sum / 3.0;
if(score[i][j] > max) max = score[i][j];
if(score[i][j] < min) min = score[i][j];
}
}
return ave;
}
int main()
{
int i, j;
float score[3][5], ave = 0;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 5; j++)
{
printf("请输入第%d个学生的第%d门成绩:\n", i + 1, j + 1);
//scanf("%lf", &score[i][j]);
scanf("%f", &score[i][j]);
}
}
ave = try1(score, 3, 5);
for(j = 0; j < 5; j++)
{
printf("平均分为:%lf", ave);
printf("最高分:%lf 最低分:%lf\n", max, min);
}
return 0;
}
|