编程打印学生数据:有5个学生,每个学生的数据包括学号、姓名、三门课程成绩,从键盘输入5个学生数据,

2024-11-07 01:29:34
推荐回答(3个)
回答1:

void main()
{/*二维数组*/
int i,j,a[3][5],b[3];
float temp_all=0,temp_c=0,s=0;
char *c[5]={"张三","王五","李四","赵六","周八"};
char *t[3]={"math","c","foxpro"};
//void change(int a[],int t);

for(i=0;i<5;i++)
{
printf("input %s 's score:",c[i]);
for(j=0;j<3;j++)
{
scanf("%d",&b[j]);
a[j][i] = b[j];
temp_c += b[j];
temp_all += a[j][i];
}
printf("%s 's average:%f \n",c[i],temp_c/3);
temp_c = 0;
}
printf("all_average:%f \n",temp_all/15);

for(j=0;j<3;j++)
{
for(i=0;i<5;i++)
{
s += a[j][i];

}
printf("%s average:%f \n",t[j],s/5);
s = 0;
}

回答2:

去看c结构体这一张,这是例题

回答3:

结构体