2022-01-06 11:50发布
关于考研C语言的几道题目,请大神赐教。另外不要嘲笑我问这种简单的问题
关于考研C语言的几道题目,请大神赐教。另外不要嘲笑我问这种简单的问题 第一道题#include struct student{char name[20];float score1,score2;float avg;};struct student stu[100];int main(){int n;int i;float all_avg=0;scanf("%d",&n); //全班学生数量for(i=1;i<=n;i++){scanf("%s %f %f",stu[i].name,&stu[i].score1,&stu[i].score2);stu[i].avg=(stu[i].score1+stu[i].score2)/2;all_avg+=stu[i].avg;}all_avg/=n;for(i=1;i<=n;i++){if(stu[i].avgstruct student{char name[20];float score1,score2,score3;float avg;};struct student stu[11];int main(){int i,j;struct student temp;for(i=1;i<=10;i++){scanf("%s %f %f %f",stu[i].name,&stu[i].score1,&stu[i].score2,&stu[i].score3);stu[i].avg=(stu[i].score1+stu[i].score2+stu[i].score3)/3;}for(i=1;i<10 i++)for(j=1;j j++){if(stu[j].avg<=stu[j+1].avg){temp stu[j];stu[j]=stu[j+1];stu[j+1] temp;}}for(i=1;i>#includestruct item{char pno[20]; char pname[20]; float amount;};struct item item[100];int main(){int i,j;struct item temp;int n;scanf("%d",&n);for(i=1;i<=n;i++){scanf("%s %s %f",item[i].pno,item[i].pname,&item[i].amount);}for(i=1;i0){temp=item[j];item[j]=item[j+1];item[j+1]=temp;}else if(strcmp(item[j].pname,item[j+1].pname)==0 && item[j].amount>item[j+1].amount){temp=item[j];item[j]=item[j+1];item[j+1]=temp;}}for(i=1;i<=n;i++){printf("%s %s %.1f\n",item[i].pno,item[i].pname,&item[i].amount);}return 0;}
最多设置5个标签!
关于考研C语言的几道题目,请大神赐教。另外不要嘲笑我问这种简单的问题 第一道题#include struct student{char name[20];float score1,score2;float avg;};struct student stu[100];int main(){int n;int i;float all_avg=0;scanf("%d",&n); //全班学生数量for(i=1;i<=n;i++){scanf("%s %f %f",stu[i].name,&stu[i].score1,&stu[i].score2);stu[i].avg=(stu[i].score1+stu[i].score2)/2;all_avg+=stu[i].avg;}all_avg/=n;for(i=1;i<=n;i++){if(stu[i].avgstruct student{char name[20];float score1,score2,score3;float avg;};struct student stu[11];int main(){int i,j;struct student temp;for(i=1;i<=10;i++){scanf("%s %f %f %f",stu[i].name,&stu[i].score1,&stu[i].score2,&stu[i].score3);stu[i].avg=(stu[i].score1+stu[i].score2+stu[i].score3)/3;}for(i=1;i<10 i++)for(j=1;j j++){if(stu[j].avg<=stu[j+1].avg){temp stu[j];stu[j]=stu[j+1];stu[j+1] temp;}}for(i=1;i>#includestruct item{char pno[20]; char pname[20]; float amount;};struct item item[100];int main(){int i,j;struct item temp;int n;scanf("%d",&n);for(i=1;i<=n;i++){scanf("%s %s %f",item[i].pno,item[i].pname,&item[i].amount);}for(i=1;i0){temp=item[j];item[j]=item[j+1];item[j+1]=temp;}else if(strcmp(item[j].pname,item[j+1].pname)==0 && item[j].amount>item[j+1].amount){temp=item[j];item[j]=item[j+1];item[j+1]=temp;}}for(i=1;i<=n;i++){printf("%s %s %.1f\n",item[i].pno,item[i].pname,&item[i].amount);}return 0;}
一周热门 更多>