
C语言基础求结构体数组成员列表中的成绩最大值并按序输出1. 用结构体数组进行传参例1#includestdafx.h#includestdio.h#definemember5//成员数#defineNAME_LEN20//姓名最大长度structst{intid;charname[NAME_LEN];doublescore;};intmax_score_id(structstst[],intsize)//结构体数组作为形参{inti,j;structsttemp;//定义结构体类型变量tempfor(i0;isize;i){for(ji1;jsize;j){if(st[i].scorest[j].score){tempst[i];st[i]st[j];st[j]temp;}}}return0;}intmain(void){intindex;structststudents[]{{101,zhang3,88.8},{102,li4,99.9},{103,wang5,66.6},{104,shun6,66.8},{105,yang7,88.6}};indexmax_score_id(students,member);//结构体数组进行传参printf(Sno\tSname\tScore\n);for(index0;indexmember;index)printf(%d\t%s\t%.2f\n,students[index].id,students[index].name,students[index].score);return0;}2. 用结构体指针进行传参例2#includestdafx.h#includestdio.h#definemember5//成员数#defineNAME_LEN20//姓名最大长度structst{intid;charname[NAME_LEN];doublescore;}*p;intmax_score_id(structst*p,intsize){//结构体指针作为形参structstmax;//定义结构体类型变量maxfor(inti0;isize;i){for(intji1;jsize;j){if((pi)-score(pj)-score){max*(pi);*(pi)*(pj);*(pj)max;}}}return0;}intmain(void){intindex;structststudents[]{{101,zhang3,88.8},{102,li4,99.9},{103,wang5,66.6},{104,shun6,66.8},{105,yang7,88.6}};pstudents;indexmax_score_id(p,member);//结构体指针进行传参printf(Sno\tSname\tScore\n);for(index0;indexmember;index){printf(%d\t%s\t%.2f\n,p-id,p-name,p-score);p;}return0;}运行结果Sno Sname Score102 li4 99.90101 zhang3 88.80105 yang7 88.60104 shun6 66.80103 wang5 66.60——以上内容是关于如何用C语言求结构体数组成员列表中的成绩最大值并按序输出希望对初学者或再次学习者有所帮助基础打扎实不怕风吹雨打 如果以上内容有错误或者内容不全望大家提出我也会继续写好每一篇博文待续未完——文优欢迎观看和提问下一篇C语言基础求两个数的最大公约数与最小公倍数