廣工Anyview試題答案-7546_第1頁(yè)
廣工Anyview試題答案-7546_第2頁(yè)
廣工Anyview試題答案-7546_第3頁(yè)
廣工Anyview試題答案-7546_第4頁(yè)
廣工Anyview試題答案-7546_第5頁(yè)
已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、/*【習(xí)題9.023】構(gòu)造體種類定義以下:structdateintyear;intmonth;intday;/定義日期構(gòu)造體種類structstudentcharname20;structdatebirth;/出壽辰期;構(gòu)造體數(shù)組s儲(chǔ)藏了n個(gè)人的名字和出壽辰期。寫(xiě)一函數(shù),求這(即出壽辰期最小)者的姓名。n個(gè)人中年齡最大*/char*oldest(students,intn)intj,k=0;for(j=1;jsj.birth.year)k=j;elseif(sk.birth.year=sj.birth.year)if(sk.birth.monthsj.birth.month)k=j;else

2、if(sk.birth.month=sj.birth.month)if(sk.birth.daysj.birth.day)k=j;;/*【習(xí)題9.025】構(gòu)造體種類定義以下:structdateintyear;intmonth;intday;/定義日期構(gòu)造體種類structstudentcharid10;/charname20;structdatebirth;/學(xué)號(hào)姓名出壽辰期;構(gòu)造體數(shù)組s儲(chǔ)藏了n個(gè)人的學(xué)號(hào)、名字和出壽辰期。寫(xiě)一函數(shù),以構(gòu)造體的形式返回這n個(gè)人中年齡最大(即出壽辰期最?。┱叩男畔?。*/structstudentoldest(structstudent

3、s,intn)intj,k=0;for(j=1;jsj.birth.year)k=j;elseif(sk.birth.year=sj.birth.year)if(sk.birth.monthsj.birth.month)k=j;elseif(sk.birth.month=sj.birth.month)if(sk.birth.daysj.birth.day)k=j;returnsk;/*【習(xí)題9.027】構(gòu)造體種類定義以下:structstudentcharid10;/charname10;/intscore5;/學(xué)號(hào)姓名各門(mén)課成績(jī);構(gòu)造體數(shù)組s儲(chǔ)藏了n個(gè)學(xué)生的學(xué)號(hào)、名字和各門(mén)課成績(jī)。編寫(xiě)函數(shù),

4、返回這n個(gè)人中第i門(mén)課成績(jī)最高者的學(xué)號(hào)。*/char*best(structstudents,intn,inti)intt=s0.scorei,k;for(intj=0;jn;j)if(tsj.scorei)t=sj.scorei;k=j;returnsk.id;/*【習(xí)題9.029】構(gòu)造體種類定義以下:structstudentcharid10;/charname10;/intscore5;/學(xué)號(hào)姓名各門(mén)課成績(jī);構(gòu)造體數(shù)組s儲(chǔ)藏了n個(gè)學(xué)生的學(xué)號(hào)、名字及其5門(mén)課成績(jī)。編寫(xiě)函數(shù),返回這n個(gè)人中5門(mén)課成績(jī)總分最高者的學(xué)號(hào)。*/char*best(structstudents,intn)intsum

5、=0,k,t=0;for(inti=0;in;i)for(intj=0;jt)t=sum;sum=0;k=i;elsesum=0;returnsk.id;/*【習(xí)題9.033】日期和鏈表結(jié)點(diǎn)的構(gòu)造體種類定義以下:structdateintyear;intmonth;intday;/structstudentNode/鏈表結(jié)點(diǎn)的構(gòu)造體種類charname10;/人名structdatebirth;/出壽辰期日期構(gòu)造體種類structstudentNode*next;構(gòu)造體鏈表L儲(chǔ)藏了n個(gè)人的名字和出壽辰期。寫(xiě)一函數(shù),求這年齡最大(即出壽辰期最?。┱叩拿?。n個(gè)人中*/char*oldest(st

6、ructstudentNode*L)/*若L是空表,則返回空指針null否則返回表中年齡最大者的名字*/structstudentNode*p;if(L=NULL)returnNULL;for(p=L-next;p!=NULL;p=p-next)if(*p).birth.year(*L).birth.year)continue;if(*p).birth.year=(*L).birth.year)if(*p).birth.month(*L).birth.month)continue;if(*p).birth.month=(*L).birth.month&(*p).birth.day=(*L).b

7、irth.day)continue;L=p;return(*L).name);/*【習(xí)題9.053】構(gòu)造體種類定義以下:structpersonintid;/charname10;/intage;/charsex;/員工號(hào)姓名年齡性別;構(gòu)造體數(shù)組personneln儲(chǔ)藏了n位員工的信息。寫(xiě)一函數(shù),返回年齡在a及以上的員工數(shù)。*/intcount(structpersonpersonnel,intn,inta)intt=0;for(inti=0;i=a)t;returnt;/*【習(xí)題9.055】構(gòu)造體種類定義以下:structpersonintid;/charname10;/intage;/ch

8、arsex;/員工號(hào)姓名年齡性別;構(gòu)造體數(shù)組personneln儲(chǔ)藏了n位員工的信息。寫(xiě)一函數(shù),返回年齡在a及以上的x性其余員工數(shù)。*/intcount(structpersonpersonnel,intn,inta,charx)intt=0;for(inti=0;i=a&personneli.sex=x)t;returnt;/*【習(xí)題9.063】構(gòu)造體種類定義以下:structcourseintcID;/charname10;/floatcredit;/intsemester;/課程號(hào),取值099課程名學(xué)分,取值05學(xué)期,取值18;構(gòu)造體數(shù)組c儲(chǔ)藏了n門(mén)課程的信息。寫(xiě)一函數(shù),修業(yè)期*/flo

9、atcreditSum(structcoursec,intn,ints)floatsum=0;for(inti=0;inext;p!=NULL;p=p-next)if(*p).semester=s)sum=(*p).credit;if(s=1)sum=(*Lc).credit;returnsum;/*【習(xí)題9.133】日期和構(gòu)造體種類定義以下:structdateintyear;intmonth;intday;/日期構(gòu)造體種類structstudent/charname10;structdatebirth;/構(gòu)造體種類人名出壽辰期;構(gòu)造體數(shù)組s儲(chǔ)藏了n個(gè)人的名字和出壽辰期。寫(xiě)一函數(shù),由數(shù)組的信

10、息及其序次構(gòu)造相應(yīng)的鏈表。鏈表的結(jié)點(diǎn)的構(gòu)造體種類定義以下:structstudentNode/構(gòu)造體種類charname10;/人名structdatebirth;/出壽辰期s中n個(gè)人structstudentNode*next;*/structstudentNode*CreateLinkList(structstudents,intn)structstudentNode*head,*p1,*p2;inti=0;p1=p2=(structstudentNode*)malloc(sizeof(structstudentNode);head=NULL;while(iname,);p1

11、-birth=si.birth;if(i=0)head=p1;elsep2-next=p1;p2=p1;p1=(structstudentNode*)malloc(sizeof(structstudentNode);i;p2-next=NULL;return(head);/*【習(xí)題9.173】課程鏈表結(jié)點(diǎn)的構(gòu)造體種類定義以下:structcourseNodeintcID;/charname10;/floatcredit;/課程鏈表結(jié)點(diǎn)的構(gòu)造體種類課程號(hào),取值099課程名學(xué)分,取值05intsemester;/學(xué)期,取值18structcourseNode*next;構(gòu)造體鏈表Lc儲(chǔ)藏了多門(mén)課程

12、的信息。寫(xiě)一函數(shù),將課程號(hào)為課程的學(xué)分更正為t。*/c的structcourseNode*creditChange(structcourseNode*Lc,intc,floatt)/*若課程c不存在,則更正不行功,返回null;否則更正該課程的學(xué)分為t,返回指向該課程結(jié)點(diǎn)的指針。*/structcourseNode*p;for(p=Lc-next;p!=NULL;p=p-next)if(*p).cID=c)(*p).credit=t;returnp;if(*Lc).cID=c)(*Lc).credit=t;returnLc;returnNULL;/*【習(xí)題9.183】課程鏈表結(jié)點(diǎn)的構(gòu)造體種類定

13、義以下:structcourseNode/課程鏈表結(jié)點(diǎn)的構(gòu)造體種類intcID;/課程號(hào),取值099charname10;/課程名floatcredit;/學(xué)分,取值05intsemester;/學(xué)期,取值18structcourseNode*next;構(gòu)造體鏈表Lc課程結(jié)點(diǎn)刪除。儲(chǔ)藏了多門(mén)課程的信息。寫(xiě)一函數(shù),將課程號(hào)為c的*/structcourseNode*deleteCourse(structcourseNode*Lc,intc)/*若在鏈表Lc中課程c不存在,則刪除不行功,返回null;否則從鏈表Lc中刪除該課程結(jié)點(diǎn),并返回指向該課程結(jié)點(diǎn)的指針。*/structcourseNode*

14、p,*q,*t;p=*Lc;while(c!=p-cID&p-next!=NULL)q=p;p=p-next;if(c=p-cID)if(p=*Lc)t=p;*Lc=p-next;elset=p;q-next=p-next;return(t);/*【習(xí)題9.302】單向鏈表的結(jié)點(diǎn)種類定義以下:structnodecharch;structnode*next;編寫(xiě)函數(shù),對(duì)單向鏈表L實(shí)現(xiàn)就地逆置,立刻所有結(jié)點(diǎn)的指針?lè)聪?,原鏈頭看作鏈尾,原鏈尾看作鏈頭,并返回逆置后鏈表的頭指針。*/structnode*inverse(structnode*L)structnode*p=L,*q;intn=0,i=0;chart;while(p!=NULL)p=p-next;n;p=L;for(;inext;if(p-ch)ch)t=p-ch,p-ch=q-ch,q-ch=t;if(q-next!=NULL)p=p-next;elsep=NULL;p=L;returnL;/*【習(xí)題9.352】單向鏈表的結(jié)點(diǎn)種類定義以下:structnodecharch;structnode*next;編寫(xiě)函數(shù),對(duì)單向鏈表L實(shí)現(xiàn)排序,即按結(jié)點(diǎn)的ch值,從小到大重構(gòu)鏈表L,并返回排序后的鏈表

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論