芳草心
第一道题#include<stdio.h> 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].avg<all_avg){printf("name:%s score1:%.1f score2:%.1f avg:%.1f\n",stu[i].name,stu[i].score1,stu[i].score2,stu[i].avg);}}return 0;}第二道题#include<stdio.h>struct 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<10;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<=5;i++){printf("name:%s score1:%.1f score2:%.1f score3:%.1f avg:%.1f\n",stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].avg);}return 0;}第三题#include<stdio.h>#include<string.h>struct 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;i<n;i++) for(j=1;j<n;j++) { if(strcmp(item[j].pname,item[j+1].pname)>0) { 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;}