#include <stdio h="">
int main (int argc, const char * argv[])
{
//定义数组
int score[5][3]={
{80,75,92},
{61,65,71},
{59,62,70},
{85,87,90},
{76,77,85},
};
float total=0;
for (int i=0;i<3; i++) {
//每统计一门课的成绩和之后,统计下一门课的成绩之前要归0
int sum=0;
//遍历
for (int j=0; j<5; j++) {
//a[j][i]取出每一列的值
sum+=score[j][i];
}
//sum/5.0f 每门课的平均分
printf("第%d门课的平均发%.2f\n",i+1,sum/5.0f);
total+=sum/5.0f;
}
printf("总平均分%.2f",total/3);
return 0;
} |
|