資源描述:
《C語(yǔ)言 課后題答案(北郵出版社)9》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
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:
2、(like1,1,1)");/*輸入逗號(hào)隔開(kāi)*/scanf("%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、#include3、io.h>#include#defineFsizeof(student)#defineNULL0typedefstructscores{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();hea
4、d=(student*)malloc(F);head->next=NULL;do{n++;printf("Pleaseinput%dstudentmessage:",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,ma
5、th,c_language):",n);scanf("%d,%d,%d",&p1->score.english,&p1->score.math,&p1->score.c_language);p1->score.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=get
6、ch();}while(ch=='y'
7、
8、ch=='Y');returnhead;}voidaverage1(student*head){student*p;intj;clrscr();p=head->next;while(p){j=p->score.all/3;printf("name:%staverage:%d",p->name,j);p=p->next;}printf("Pressenykeyreturn.");getch();}voidaverage2(student*head){student*p;i
9、ntn=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("averageenglishis:%daveragemathis:%daveragec_languageis:%dt",temp1/n,temp2/n,temp3/n);}student*sort(student*head){
10、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=