实验六

#include<stdio.h>
float average3(float a,float b,float c)
{float d,f;
d=a+b+c;
f=d/3;
return f;
}
float average5(float a,float b,float c,float d,float e)
{float x,f;
x=a+b+c+d+e;
f=x/5;
return f;
}
int main()
{float c1,c2,c3,c4,c5,a1,a2,a3;
int i,j;
 float a[5][3];
for(i=0;i<5;i++)
{for(j=0;j<3;j++)
{scanf("%f",&a[i][j]);
}
}
c1=average3(a[0][0],a[0][1],a[0][2]);
c2=average3(a[1][0],a[1][1],a[1][2]);
c3=average3(a[2][0],a[2][1],a[2][2]);
c4=average3(a[3][0],a[3][1],a[3][2]);
c5=average3(a[4][0],a[4][1],a[4][2]);
printf("五位同学的平均分分别为%f\t%f\t%f\t%f\t%f\n",c1,c2,c3,c4,c5);
a1=average5(a[0][0],a[1][0],a[2][0],a[3][0],a[4][0]);
a2=average5(a[0][1],a[1][1],a[2][1],a[3][1],a[4][1]);
a3=average5(a[0][2],a[1][2],a[2][2],a[3][2],a[4][2]);
printf("三门课的平均成绩分别为%f\t%f\t%f\n",a1,a1,a3);
return 0;
}

 

posted on 2019-06-06 14:59  甄珍123  阅读(149)  评论(0编辑  收藏  举报

导航