![廣工Anyview試題答案_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/8fd45366-0a15-4be8-bac5-979a7b81434d/8fd45366-0a15-4be8-bac5-979a7b81434d1.gif)
![廣工Anyview試題答案_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/8fd45366-0a15-4be8-bac5-979a7b81434d/8fd45366-0a15-4be8-bac5-979a7b81434d2.gif)
![廣工Anyview試題答案_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/27/8fd45366-0a15-4be8-bac5-979a7b81434d/8fd45366-0a15-4be8-bac5-979a7b81434d3.gif)
版權(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 】結(jié)構(gòu)體類型定義如下:struct dateint year; int month; int day; /定義日期結(jié)構(gòu)體類型struct student char name20;struct date birth; /出生日期;結(jié)構(gòu)體數(shù)組 s 存儲(chǔ)了 n 個(gè)人的名字和出生日期。寫一函數(shù),求這 n 個(gè)人中年齡最大 (即出生日期最小)者的姓名。*/char *oldest(student s, int n)int j,k=0;for(j=1;jsj.birth.year) k=j;else if(sk.birth.year=sj.birth.year) if(sk.birt
2、h.monthsj.birth.month) k=j;else if(sk.birth.month=sj.birth.month) if(sk.birth.daysj.birth.day) k=j;return ;/*【習(xí)題 9.025 】結(jié)構(gòu)體類型定義如下:struct dateint year; int month; int day; /定義日期結(jié)構(gòu)體類型struct student char id10; /學(xué)號(hào)char name20; /姓名struct date birth; /出生日期;結(jié)構(gòu)體數(shù)組 s 存儲(chǔ)了 n 個(gè)人的學(xué)號(hào)、名字和出生日期。寫一函數(shù),以結(jié)構(gòu)體的形式 返
3、回這 n 個(gè)人中年齡最大(即出生日期最小)者的信息。*/struct student oldest(struct student s, int n)int j,k=0;for(j=1;jsj.birth.year) k=j;else if(sk.birth.year=sj.birth.year)if(sk.birth.monthsj.birth.month) k=j;else if(sk.birth.month=sj.birth.month)if(sk.birth.daysj.birth.day) k=j;return sk;/*【習(xí)題 9.027 】結(jié)構(gòu)體類型定義如下:學(xué)號(hào) 姓名 各門課成績(jī)
4、struct student char id10; / char name10; / int score5; /;結(jié)構(gòu)體數(shù)組 s 存儲(chǔ)了 n 個(gè)學(xué)生的學(xué)號(hào)、名字和各門課成績(jī)。編寫 函數(shù),返回這 n 個(gè)人中第 i 門課成績(jī)最高者的學(xué)號(hào)。*/ char *best(struct student s, int n, int i) int t=s0.scorei,k;for(int j=0;jn;j ) if(tsj.scorei) t=sj.scorei;k=j; return sk.id;/*學(xué)號(hào)姓名 各門課成績(jī)【習(xí)題 9.029 】結(jié)構(gòu)體類型定義如下: struct student char i
5、d10; / char name10; / int score5; /;結(jié)構(gòu)體數(shù)組 s 存儲(chǔ)了 n 個(gè)學(xué)生的學(xué)號(hào)、名字及其 5 門課成績(jī)。編寫 函數(shù),返回這 n 個(gè)人中 5 門課成績(jī)總分最高者的學(xué)號(hào)。*/char *best(struct student s, int n) int sum=0,k,t=0; for(int i=0;in;i )for(int j=0;jt)t=sum;sum=0;k=i; else sum=0;return sk.id;日期結(jié)構(gòu)體類型 鏈表結(jié)點(diǎn)的結(jié)構(gòu)體類型人名 出生日期*/習(xí)題 9.033 】日期和鏈表結(jié)點(diǎn)的結(jié)構(gòu)體類型定義如下: struct dateint
6、year; int month; int day; / struct studentNode / char name10; / struct date birth; / struct studentNode *next;結(jié)構(gòu)體鏈表 L 存儲(chǔ)了 n 個(gè)人的名字和出生日期。寫一函數(shù),求這 n 個(gè)人中 年齡最大(即出生日期最小)者的名字。char *oldest(struct studentNode *L)/* 若 L 是空表,則返回空指針 null 否則返回表中年齡最大者的名字*/struct studentNode *p;if(L=NULL) return NULL;for(p=L-next;p
7、!=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).birth.day) continue;L=p;return(*L).name);*習(xí)題 9.053 】結(jié)構(gòu)體類型定義如下:struct person int id; /員工號(hào)char name10; /姓名in
8、t age;/年齡char sex;/性別;結(jié)構(gòu)體數(shù)組 personneln 存儲(chǔ)了 n 位員工的信息 寫一函數(shù),返回年齡在 a 及以上的員工數(shù)。*/int count(struct person personnel, int n, int a)int t=0;for(int i=0;i=a)t ; return t;*習(xí)題 9.055 】結(jié)構(gòu)體類型定義如下:struct person int id; /員工號(hào)char name10; /姓名int age;/年齡char sex;/性別;結(jié)構(gòu)體數(shù)組 personneln 存儲(chǔ)了 n 位員工的信息。 寫一函數(shù),返回年齡在a及以上的x性別的員工數(shù)
9、。 */int count(struct person personnel, int n, int a, char x) int t=0;for(int i=0;i=a&personneli.sex=x)t ; return t;*習(xí)題 9.063 】結(jié)構(gòu)體類型定義如下: struct course int cID; / char name10; / float credit; / int semester; /課程號(hào),取值 099 課程名 學(xué)分,取值 05 學(xué)期,取值 18;結(jié)構(gòu)體數(shù)組c存儲(chǔ)了 n門課程的信息。寫一函數(shù),求學(xué)期 s的總學(xué)分*/float creditSum(struct co
10、urse c, int n, int s) float sum=0; for(int i=0;inext;p!=NULL;p=p-next) if(*p).semester=s) sum =(*p).credit;if(s=1)sum =(*Lc).credit;return sum;/*【習(xí)題 9.133 】日期和結(jié)構(gòu)體類型定義如下:struct dateint year; int month; int day; /日期結(jié)構(gòu)體類型struct student / 結(jié)構(gòu)體類型 char name10; /人名struct date birth; /出生日期;結(jié)構(gòu)體數(shù)組 s 存儲(chǔ)了 n 個(gè)人的名
11、字和出生日期。寫一函數(shù),由數(shù)組 s 中 n 個(gè)人 的信息及其順序構(gòu)造相應(yīng)的鏈表。鏈表的結(jié)點(diǎn)的結(jié)構(gòu)體類型定義如下:struct studentNode /結(jié)構(gòu)體類型 char name10; /人名struct date birth; /出生日期struct studentNode *next;*/struct studentNode *CreateLinkList(struct student s, int n)struct studentNode *head,*p1,*p2;int i=0;p1=p2=(struct studentNode *) malloc(sizeof(struct s
12、tudentNode); head=NULL;while(iname,); p1-birth=si.birth;if(i=0) head=p1;else p2-next=p1;p2=p1;p1=(struct studentNode *) malloc(sizeof(struct studentNode); i;p2-next=NULL; return (head);習(xí)題 9.173 】課程鏈表結(jié)點(diǎn)的結(jié)構(gòu)體類型定義如下:struct courseNode / int cID; /char name10; / float credit; /課程鏈表結(jié)點(diǎn)的結(jié)構(gòu)體類型 課程號(hào),取值 0
13、99 課程名學(xué)分,取值 05int semester; / 學(xué)期,取值 18 struct courseNode *next;結(jié)構(gòu)體鏈表 Lc 存儲(chǔ)了多門課程的信息。寫一函數(shù),將課程號(hào)為 c 的 課程的學(xué)分修改為 t 。*/ struct courseNode *creditChange(struct courseNode *Lc, int c, float t) /* 若課程 c 不存在,則修改不成功,返回 null;否則修改該課程的學(xué)分為 t ,返回指向該課程結(jié)點(diǎn)的指針。*/struct courseNode *p;for(p=Lc-next;p!=NULL;p=p-next)if(*p)
14、.cID=c)(*p).credit=t; return p;if(*Lc).cID=c)(*Lc).credit=t;return Lc;return NULL;習(xí)題 9.183 】課程鏈表結(jié)點(diǎn)的結(jié)構(gòu)體類型定義如下:struct courseNode / int cID; /char name10; /float credit; / int semester; / struct courseNode *next;課程鏈表結(jié)點(diǎn)的結(jié)構(gòu)體類型 課程號(hào),取值 099 課程名學(xué)分,取值 05學(xué)期,取值 18;結(jié)構(gòu)體鏈表 Lc 存儲(chǔ)了多門課程的信息。寫一函數(shù),將課程號(hào)為 c 的 課程結(jié)點(diǎn)刪除。*/str
15、uct courseNode *deleteCourse(struct courseNode *Lc, int c)/* 若在鏈表 Lc 中課程 c 不存在,則刪除不成功,返回 null; 否則從鏈表 Lc 中刪除該課程結(jié)點(diǎn),并返回指向該課程結(jié)點(diǎn)的指針 */struct courseNode *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)類型定義如下:
16、struct nodechar ch;struct node *next;編寫函數(shù),對(duì)單向鏈表 L 實(shí)現(xiàn)就地逆置,即將所有結(jié)點(diǎn) 的指針?lè)聪颍滎^當(dāng)作鏈尾,原鏈尾當(dāng)作鏈頭,并返 回逆置后鏈表的頭指針。*/struct node *inverse(struct node *L)struct node *p=L,*q;int n=0,i=0; char t;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; else p=NULL;p=L;return L;/*【習(xí)題 9.352 】單向鏈表的結(jié)點(diǎn)類型定義如下:struct nodechar ch;struct node *next;編寫函數(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年眉山貨運(yùn)資格證模擬考試新題庫(kù)
- 電梯加件協(xié)議書(shū)(2篇)
- 電力需求預(yù)測(cè)合同(2篇)
- 2024-2025學(xué)年四年級(jí)語(yǔ)文上冊(cè)第五單元橋12橋之思備課教案北師大版
- 湘教版數(shù)學(xué)七年級(jí)下冊(cè)2.2.2《運(yùn)用完全平方公式進(jìn)行計(jì)算》聽(tīng)評(píng)課記錄
- 律師事務(wù)所年度檢查考核總結(jié)
- 第三季度財(cái)務(wù)工作總結(jié)
- 采購(gòu)計(jì)劃年終工作總結(jié)
- 聽(tīng)評(píng)課記錄二年級(jí)語(yǔ)文
- 領(lǐng)導(dǎo)給員工的評(píng)語(yǔ)與希望
- 口腔科院感知識(shí)培訓(xùn)針刺傷
- 土地管理學(xué)課件
- 《認(rèn)識(shí)人民幣》完整版
- 工程施工風(fēng)險(xiǎn)研判報(bào)告及安全風(fēng)險(xiǎn)管控防范應(yīng)對(duì)措施
- 會(huì)陰切開(kāi)傷口裂開(kāi)的護(hù)理查房
- ptmeg生產(chǎn)工藝技術(shù)
- 仁愛(ài)版八年級(jí)英語(yǔ)下冊(cè)全冊(cè)教案
- 醫(yī)療安全不良事件警示教育課件
- 《幼兒園健康》課件
- 醫(yī)保物價(jià)培訓(xùn)課件
- 食堂餐廳服務(wù)方案投標(biāo)方案(技術(shù)標(biāo))
評(píng)論
0/150
提交評(píng)論