




版權(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司房租租憑合同范本
- 勞動(dòng)安全協(xié)議合同范本
- 包子店加盟簽約合同范本
- 人工打草合同范本
- 沖孔加工銷售合同范本
- 2024年河南省直第三人民醫(yī)院招聘筆試真題
- 第14課《回憶我的母親》教學(xué)設(shè)計(jì) 2024-2025學(xué)年統(tǒng)編版語(yǔ)文七年級(jí)上冊(cè)
- 力工合同范例
- 中國(guó)鐵建合同范本
- 包月工作合同范本
- 2024版消防設(shè)計(jì)質(zhì)量問(wèn)題案例分析手冊(cè)建筑機(jī)電專業(yè)
- 《業(yè)財(cái)一體化實(shí)訓(xùn)教程-金蝶云星空V7.5》
- 工業(yè)機(jī)器人工作站系統(tǒng)組建課件 5.1康耐視is2000工業(yè)相機(jī)視覺(jué)識(shí)別操作
- 人教版二年級(jí)數(shù)學(xué)下冊(cè)第一單元綜合測(cè)評(píng)卷(含答案)
- 社區(qū)意識(shí)形態(tài)工作2025年度工作計(jì)劃
- 2025年山東省濟(jì)南廣播電視臺(tái)招聘30人歷年管理單位筆試遴選500模擬題附帶答案詳解
- DG-TJ 08-2048-2024 民用建筑電氣防火設(shè)計(jì)標(biāo)準(zhǔn)
- 2025年中智集團(tuán)招聘筆試參考題庫(kù)含答案解析
- 肝癌圍手術(shù)期的護(hù)理
- 黑龍江省哈爾濱市南崗區(qū)2024-2025學(xué)年九年級(jí)上學(xué)期期末考試英語(yǔ)試題(含答案)
- 殘疾人就業(yè)培訓(xùn)
評(píng)論
0/150
提交評(píng)論