版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、經(jīng)典 c 程序 100 例=71-80【程序 71】題目:編寫 input()和 output()函數(shù)輸入,輸出 5 個(gè)學(xué)生的數(shù)據(jù)程序分析:程序源代碼: #define N 5 struct student char num6; char name8;score4; stuN; input(stu)struct student stu;i,j; for(i=0;iN;i+)。 prprf(n please input %d of %dn,i+1,N);f(num: );scanf(%s,stui.num);prf(name: );scanf(%s,);for(j=0;j3;j
2、+) prf(score %d.,j+1);scanf(%d,&stui.scorej);prf(n);pr(stu)struct student stu;pri,j;f(nNo. Name Sco1 Sco2 Sco3n);for(i=0;iN;i+) prf(%-6s%-10s,stui.num,);for(j=0;jn);for(i=0;idata=num;ptr-next=(link)malloc(sizeof(node); if(i=4) ptr-next=NULL;else ptr=ptr-next;ptr=head; while(ptr!=NULL) prf(T
3、he value is =%dn,ptr-data);ptr=ptr-next;=【程序 73】題目:反向輸出一個(gè)鏈表。程序分析:程序源代碼:/*reverse output a list*/ #include stdlib.h #include stdio.h struct listdata;struct list *next;typedef struct list node; typedef node *link;void main() link ptr,head,tail; num,i;tail=(link)malloc(sizeof(node); tail-next=NULL;ptr=
4、tail;prf(nplease input 5 data=n);for(i=0;idata=num;head=(link)malloc(sizeof(node); head-next=ptr;ptr=head;ptr=ptr-next; while(ptr!=NULL) prf(The value is =%dn,ptr-data);ptr=ptr-next;=【程序 74】題目:連接兩個(gè)鏈表。程序分析:程序源代碼: #include stdlib.h #include stdio.h struct listdata;struct list *next;typedef struct list
5、 node; typedef node *link;link delete_nink poif (tmp=NULL) /*deleteer,link tmp)node*/return poelseer-next; if(tmp-next-next=NULL)/*deletmp-next=NULL;ast node*/else /*delete the other node*/tmp-next=tmp-next-next;return poer;void selection_sort(link poer,num)link tmp,btmp; i,min;for(i=0;idata;btmp=NU
6、LL;while(tmp-next) if(mmp-next-data)mmp-next-data;btmp=tmp;tmp=tmp-next;pr polinkf(40: %dn,min);er=delete_node(poer,btmp);create_list(array,num) link tmp1,tmp2,poi;er;popoer=(link)malloc(sizeof(node);er-data=array0;tmp1=poer;for(i=1;inext=NULL;tmp2-data=arrayi; tmp1-next=tmp2; tmp1=tmp1-next;return
7、poer;link concatenaink po link tmp;er1,link poer2)tmp=poer1;while(tmp-next)tmp=tmp-next;tmp-next=poer2;return poer1;void main(void)arr1=3,12,8,9,11;link ptr; ptr=create_list(arr1,5); selection_sort(ptr,5);=【程序 75】題目:放松一下,算一道簡(jiǎn)單的題目。程序分析:程序源代碼: main()i,n; for(i=1;i1)break; if(n%2=0)prf(Even=);sum=dcall
8、(peven,n);elseprf(Odd=);sum=dcall(podd,n);prf(%f,sum);float peven(float s;i; s=1;n)for(i=2;i=n;i+=2) s+=1/(float)i;return(s);float podd(n)n;float s;i; s=0;for(i=1;i=n;i+=2) s+=1/(float)i;return(s);float dcall(fp,n) float (*fp)();n;float s; s=(*fp)(n);return(s);=【程序 77】題目:填空練習(xí)(指向指針的指針)程序分析:程序源代碼: mai
9、n() char *s=man,woman,girl,boy,sister; char *q;k;for(k=0;k5;k+);/*這里填寫什么語(yǔ)句*/f(%sn,*q);pr=【程序 78】題目:找到最大的人,并輸出。請(qǐng)找出程序中程序分析:程序源代碼: #define N 4 #include stdio.h問(wèn)題。sic struct man char name20;age;N=li,18,wang,19,zhang,20,sun,22;main()struct man *q,*p; i,m=0;p=;for (i=0;iN;i+)if(mage) q=p+;m=q-age;prf(%s,%
10、d,(*q).name,(*q).age);=【程序 79】題目:字符串排序。程序分析:程序源代碼: main()charchar pr*str120,*str220,*str320; swap();f(please input three stringsn);scanf(%s,str1);scanf(%s,str2);scanf(%s,str3); if(strcmp(str1,str2)0) swap(str1,str2); if(strcmp(str1,str3)0) swap(str1,str3); if(strcmp(str2,str3)0) swap(str2,str3);pr prchar charcharf(after being sortedn);f(%sn%sn%sn,str1,str2,str3);swap(p1,p2)*p1,*p2;*p20;strcpy(p,p1);strcpy(p1,p2);strcpy(p2,p);=【程序 80】題目:海灘上有一堆桃子,五只猴子來(lái)分。第一只猴子把這堆桃子憑據(jù)分為五份,多了一個(gè),這只猴子把多的一個(gè)扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了一個(gè),它同樣把多的一個(gè)扔入海中,拿走了一份,第三、第四、第五只猴子都是這樣做的,問(wèn)海灘上
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026江西吉安吉星養(yǎng)老服務(wù)有限公司面向社會(huì)招聘護(hù)理員參考考試題庫(kù)附答案解析
- 2026江蘇東布洲科技園集團(tuán)有限公司下屬子公司招聘勞務(wù)派遣人員1人備考考試題庫(kù)附答案解析
- 2026山東聊城市新聊泰城市建設(shè)發(fā)展有限公司首批用人招聘10人參考考試試題附答案解析
- 生豬屠宰場(chǎng)生產(chǎn)制度
- 汽車生產(chǎn)備料管理制度
- 安全生產(chǎn)風(fēng)險(xiǎn)研判會(huì)制度
- 鋁錠生產(chǎn)日常管理制度
- 鋼廠生產(chǎn)車間制度
- 2026上??萍即髮W(xué)物質(zhì)科學(xué)與技術(shù)學(xué)院電鏡平臺(tái)招聘工程師1名備考考試試題附答案解析
- 按生產(chǎn)計(jì)劃發(fā)料制度
- GMP設(shè)備管理培訓(xùn)
- 基層護(hù)林員巡山護(hù)林責(zé)任細(xì)則
- 2025-2026學(xué)年廣東省深圳市福田區(qū)六年級(jí)(上)期末模擬數(shù)學(xué)試卷
- 智慧育兒:家庭教育經(jīng)驗(yàn)分享
- 兩委換屆考試題庫(kù)及答案
- 2025廣東湛江市看守所招聘醫(yī)務(wù)人員1人考試筆試備考試題及答案解析
- GB/T 36935-2025鞋類鞋號(hào)對(duì)照表
- 食品中標(biāo)后的合同范本
- 高階老年人能力評(píng)估實(shí)踐案例分析
- 2025年全國(guó)職業(yè)院校技能大賽高職組(研學(xué)旅行賽項(xiàng))考試題庫(kù)(含答案)
- 創(chuàng)意文案寫作技巧與實(shí)戰(zhàn)案例
評(píng)論
0/150
提交評(píng)論