正在加载图片...
maino 第11章第5节 srtuct student {ir nt num char name 30 float score 3 定义结构体数组 struct student stu 10; float ave 3,aves Int I for(i=0;i<10;i++) printf(“ input data of No.%d”,i); &stuiscore[l, &stuiscore) 输入数据 scanf(s%d, %S,%,%f,%f", &stu! i). num, stul i). name, &stu(i]. score(01, L X ave|0]=0.0;avel=0.0;ave2|=0.0 for(i=0;i<10;计 for(j=0:j3:j++) 求各科平均分 ave jl=ave[jl+stui score; ave[0]=ave[0 10.0; ave1Fave 1/10.0; ave 2]=ave 2/10.0 aves=(stu[O) score[0+stu0-score[1]+stu[0) score[2)/3.0 k=0: for(i=0;i10;i++) 求最高分数的学 i( stuiscore[ol+ -stui score 1]+stu i score)30>aes)生位置k faves=(stui]- score[0]+stui score[1+stuli score[2)3.0main() {srtuct student {int num; char name[30]; float score[3]; }; struct student stu[10]; float ave[3], aves int i,j,k; for (i=0;i<10;i++) {printf(“input data of No. %d”, i); scanf(“%d,%s,%f,%f,%f”,&stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]); } ave[0]=0.0; ave[1]=0.0; ave[2]=0.0; for(i=0; i<10; i++) for(j=0;j<3;j++) ave[j]=ave[j]+stu[i].score[j]; ave[0]=ave[0]/10.0; ave[1]=ave[1]/10.0; ave[2]=ave[2]/10.0; aves=(stu[0].score[0]+stu[0].score[1]+stu[0].score[2])/3.0; k=0; for (i=0; i<10;i++) if ((stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3.0>aves) {aves=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3.0; k=i;} 第11章第5节 定义结构体数组 输 入 数 据 求各科平均分 求最高分数的学 生位置k
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有