版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、chang2、#include<stdio.h>structstudents{charsid[100];charname[100];floatscore[3];}student;voidmain( ){inti;floatj;printf(\Pleaseinputsid:);scanf(%s,student.sid);printf(\Pleaseinputname:);scanf(%s,););/*printf(\Pleaseinput3score:(like1,1,1)輸入逗號分開*/scanf(%f,%f,%f,&student.score[0],&student.score[1],&student.score[2]);printf(\sid=%s,student.sid);printf(\name=%s,);j=(student.score[0]+student.score[1]+student.score[2])/3.0;printf(\average=%.2f,j);getch( );}3#include<stdio.h>#include<string.h>#defineFsizeof(student)1/17#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( );head=(student*)malloc(F);head->next=NULL;don++;{printf(\\nPleaseinput%dstudentmessage:\n\n,n);,n);printf(\studentsid:p1=(student*)malloc(F);p1->next=NULL;scanf(%s,p1->sid);,n);printf(\\t%dstudentname:scanf(%s,p1->name);,n);printf(\%d\t%dstudentscores(englesh,math,c_language):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;}2/17printf(\\n\t\t\tContinueorback(pressy/n):);ch=getch( );}while(ch=='y'||ch=='Y');returnhead;}voidaverage1(student*head)intj;{student*p;clrscr( );p=head->next;while(p){j=p->score.all/3;printf(\\nname:%s\taverage:%d,p->name,j);p=p->next;}printf(\\n\nPressenykeyreturn.);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(\\naverageenglishis:%d\naveragemathis:%d\naveragec_language3/17is:%d\t,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=p->next)for(q=p->next;q;q=q->next){r=p;if(q->score.all>r->score.all)r=q;if(r!=p){strcpy(s,p->sid);strcpy(n,p->name);temp1=p->score.english;temp2=p->score.math;temp3=p->score.c_language;temp4=p->score.all;strcpy(p->sid,r->sid);strcpy(p->name,r->name);p->score.english=r->score.english;p->score.math=r->score.math;p->score.c_language=r->score.c_language;p->score.all=r->score.all;strcpy(r->sid,s);strcpy(r->name,n);r->score.english=temp1;r->score.math=temp2;r->score.c_language=temp3;r->score.all=temp4;}}returnhead1;4/17}voidoutput(student*head){student*head2,*p;inti=1;clrscr( );head2=sort(head);for(p=head2->next;p!=NULL;p=p->next)printf(\\nname:%s\tsid:%s\tenglish:%d\tmath:%d\tc_language:%d\taverage:%d\tmingci:%d,p->name,p->sid,p->score.english,p->score.math,p->score.c_language,p->score.all/3,i++);average2(head);printf(\\n\n\t\tPressenykeyback.);getch( );}voidmain( ){student*head,*p1,*p2;inti=0,j=1;head=input( );do{clrscr( );sort.\n\n(4):output.\n\n\naverage2.\n\n(3):average1.\n\n(2):printf(\\n(1):Pleasechoose:);scanf(%d,&i);switch(i)break;{case1:average1(head);printf(\\n\nPressenykeycase2:5/17clrscr( );average2(head);retuen.);getch( );break;case3:clrscr( );p1=sort(head);for(p2=p1->next;p2!=NULL;p2=p2->next)printf(\\t\tname:%s\tmingci:%d,p2->name,j++);printf(\\n\nPressenykeyback.);getch( );break;case4:output(head);break;default:printf(\Yourchooseisnotright.);break;}}while(i!=-1);}4、#include<stdio.h>#include<string.h>#defineNULL0#defineFsizeof(worker)typedefstructwork{charsid[15];charname[15];intmoney;structwork*next;6/17}worker;intmin=0,max=0;chara[15],b[15];worker*input( ){worker*head,*p,*q;intn=0;charch;head=(worker*)malloc(F);head->next=0;do{n++;p=(worker*)malloc(F);p->next=0;printf(\\n\tPleaseinput%dworkermessage:,n);printf(\%dworkersid:,n);scanf(%s,p->sid);printf(\%dworkername:,n);scanf(%s,p->name);printf(\%dworkermoney:,n);scanf(%d,&p->money);if(n==1){head->next=p;q=p;max=p->money;strcpy(a,p->name);min=p->money;strcpy(b,p->name);}else{q->next=p;if(p->money>max)7/17{max=p->money;strcpy(a,p->name);}if(p->money<min){min=p->money;strcpy(b,p->name);}q=p;}printf(\\t\ty/n);ch=getch( );}while(ch=='y'||ch=='Y');returnhead;}voidoutput( ){clrscr( );%d\t\tnameis:%s\n\n,max,a);printf(\Themaxmoneyis:%d\t\tnameis:%s,min,b);printf(\Theminmoneyis:}voidmain( ){input( );output( );getch( );}、6、5椣據(jù)畬敤獜摴?jié)潠?defineFsizeof(stu)#defineNULL0typedefstructstudent{intsid;intaverage;structstudent*next;}stu;stu*head;stu*create( )8/17stu*p1,*p2;{intn=0;charch;head=(stu*)malloc(F);head->next=NULL;don++;{\n\n,n);printf(\\nPleaseinput%dstudentmessage:,n);printf(\%dstudentsid:p1=(stu*)malloc(F);p1->next=NULL;scanf(%d,&p1->sid);,n);printf(\\t%dstudentaverage:scanf(%d,&p1->average);{head->next=p1;p2=p1;}else{p2->next=p1;if(n==1)p2=p1;}printf(\\n\t\t\tContinueorback(pressy/n):);ch=getch( );}while(ch=='y'||ch=='Y');returnhead;}stu*select(stu*head,intx){stu*s;s=head->next;while(s)9/17{if(s->sid==x)break;s=s->next;}returns;}stu*insert(stu*head,intx,inty){stu*p,*r,*q;clrscr( );p=head->next;r=(stu*)malloc(sizeof(stu));r->sid=x;r->average=y;假如插入空表if(p==NULL)/**/{p=r;r->next=NULL;printf(\insertsuccess!!);}else{while(x>p->sid)找到插入的地點(diǎn),按學(xué)號大小。/*到地點(diǎn)或許到了表尾都*/會跳出循環(huán))if(p->next==NULL)break;p=p->next;{}插到中間地點(diǎn)if(x<p->sid)/**/{r->sid=p->sid;r->average=p->average;p->sid=x;p->average=y;r->next=p->next;p->next=r;10/17printf(\insertsuccess!!);}學(xué)號不可以同樣elseif(x==p->sid)/**/printf(\Error--->yourinputthissamesid.);*/插到末端else/*{p->next=r;(找insertsuccess!!);}}returnhead;}的結(jié)點(diǎn)的指針獲得地點(diǎn)為nstu*get(stu*head,intn)/**/{stu*p;inti;p=head->next;returnhead;if(n==0)else{for(i=1;i<n;i++)p=p->next;returnp;}}stu*delete(stu*head,intsid){stu*p,*q;inttemp=0,i=0;p=head->next;11/17if(!p){pressenykeyback.);getch( );returnhead;}/*printf(\listisempty.*/表空else*/{while(p)查找學(xué)號為/*的結(jié)點(diǎn)的指針sid{i++;*/sid標(biāo)志學(xué)號為/*的結(jié)點(diǎn)的地點(diǎn)if(p->sid==sid)*/{temp=1;break;}/*temp=1標(biāo)志找到了p=p->next;}if(temp==1)/*假如有學(xué)號為sid的結(jié)點(diǎn)*/*/的前一個(gè)結(jié)點(diǎn)的指針獲得sidq=get(head,i-1);/*{q->next=p->next;free(p);printf(\\ndeletesucess!!!);returnhead;}else/*沒有找到*/{printf(\\nNOthisdata.\n);returnhead;}}}voidprint(stu*head){stu*p;p=head->next;if(!p){printf(\listisempty.pressenykeyback.);getch( );}{printf(\%d:\t%d,p->sid,p->average);p=p->next;12/17}}main( )while(p){stu*p1,*p2;charch1;intn,i=0,j=0;head=create( );do{clrscr( );printf(\1.insert.);printf(\2.select.);printf(\3.delect.);printf(\4.printlist.);printf(\5.EXIT);............choice(1-5).............);printf(\ch1=getch( );switch(ch1){case'1':{clrscr( );printf(\pleaseinputinsertsid.andaverage(like1,1):);scanf(%d,%d,&i,&j);13/17head=insert(head,i,j);printf(\\n\nPressenykeyback.);getch( );break;}case'2':{clrscr( );printf(\inputyouwanttoseletesid:);scanf(%d,&n);p1=select(head,n);{if(p1)printf(\sid:%d\taverage:%d,p1->sid,p1->average);printf(\Nothisdata.);else}printf(\\n\nPressenykeyback.);getch( );break;}'3':caseclrscr( );printf(\Pleaseinputyouwantdeletesid:);{scanf(%d,&n);head=delete(head,n);printf(\\n\nPressenykeyback.);getch( );break;}case'4':{clrscr( );14/17printf(Allinformation:);print(head);printf(\\n\nPressenykeyback.);getch( );break;}case'5':return;pressenykeyback.);getch( );default:printf(\\nYourenterisnotright.}}while(n);}7#include<stdio.h>#defineFsizeof(L)typedefstructlist{chardata;structlist*next;}L;L*set_list( )L*head,
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 小學(xué)一年級數(shù)學(xué)口算練習(xí)題全套
- 學(xué)校瓷磚施工方案(3篇)
- 0-3歲早教保育與發(fā)展關(guān)鍵資料
- 宜昌地面施工方案(3篇)
- 橋鋼筋施工方案(3篇)
- 低溫油漆施工方案(3篇)
- 圖文展板施工方案(3篇)
- 客戶催款活動策劃方案(3篇)
- 吹沙工地施工方案(3篇)
- ups突發(fā)應(yīng)急預(yù)案(3篇)
- 雨課堂在線學(xué)堂《創(chuàng)業(yè)管理四季歌:藝術(shù)思維與技術(shù)行動》單元考核測試答案
- 2025年水利工程質(zhì)量檢測員資格考試模擬試題:(巖土工程)復(fù)習(xí)題庫及答案
- 廣東省深圳市羅湖區(qū)2024-2025學(xué)年六年級上學(xué)期語文11月期中試卷(含答案)
- 耳聾護(hù)理查房記錄
- 中國臨床腫瘤學(xué)會(CSCO)食管癌診療指南2025
- 二保焊培訓(xùn)課件
- 工程變更通知(ECN)流程及管理規(guī)范
- 2025至2030中國助聽器行業(yè)調(diào)研及市場前景預(yù)測評估報(bào)告
- 2025-2030碳纖維復(fù)合材料成型設(shè)備技術(shù)發(fā)展與市場前景
- 2025時(shí)事政治試題庫(附含參考答案)
- 宮腔鏡手術(shù)的護(hù)理常規(guī)
評論
0/150
提交評論