资源描述:
《C语言课后题答案(北邮出版社).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1、li45300.0chang30200.0chang2、#includestructstudents{charsid[100];charname[100];floatscore[3];}student;voidmain(){inti;floatj;printf("Pleaseinputsid:");scanf("%s",student.sid);printf("Pleaseinputname:");scanf("%s",student.name);printf("Pleaseinput3score:(like1,1,1)");/*输入逗号隔开*/sc
2、anf("%f,%f,%f",&student.score[0],&student.score[1],&student.score[2]);printf("sid=%s",student.sid);printf("name=%s",student.name);j=(student.score[0]+student.score[1]+student.score[2])/3.0;printf("average=%.2f",j);getch();}3、#include#include#defineFsizeof(student)#defin
3、eNULL0typedefstructscores{intenglish;intmath;intc_language;intall;}TP;typedefstructstudents{charsid[15];charname[15];TPscore;structstudents*next;}student;student*input(){student*head,*p1,*p2;intn=0;charch;clrscr();head=(student*)malloc(F);head->next=NULL;do{n++;printf("Pleaseinput%dstudentm
4、essage:",n);printf("t%dstudentsid:",n);p1=(student*)malloc(F);p1->next=NULL;scanf("%s",p1->sid);printf("t%dstudentname:",n);scanf("%s",p1->name);printf("t%dstudentscores(englesh,math,c_language):",n);scanf("%d,%d,%d",&p1->score.english,&p1->score.math,&p1->score.c_language);p1->score
5、.all=p1->score.english+p1->score.math+p1->score.c_language;if(n==1){head->next=p1;p2=p1;}else{p2->next=p1;p2=p1;}printf("tttContinueorback(pressy/n):");ch=getch();}while(ch=='y'
6、
7、ch=='Y');returnhead;}voidaverage1(student*head){student*p;intj;clrscr();p=head->next;while(p){j=p->score.all/
8、3;printf("name:%staverage:%d",p->name,j);p=p->next;}printf("Pressenykeyreturn.");getch();}voidaverage2(student*head){student*p;intn=0,temp1=0,temp2=0,temp3=0;p=head->next;while(p){temp1+=p->score.english;temp2+=p->score.math;temp3+=p->score.c_language;p=p->next;n++;}printf("avera
9、geenglishis:%daveragemathis:%daveragec_languageis:%dt",temp1/n,temp2/n,temp3/n);}student*sort(student*head){student*head1,*p,*q,*r;inttemp1=0,temp2=0,temp3=0,temp4;chars[15],n[15];head1=head;for(p=head1->next;p->next!=NULL;p=