![[精品]C程序答案_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/5/970032c7-9b7d-44f0-8dd3-a153f9e5de12/970032c7-9b7d-44f0-8dd3-a153f9e5de121.gif)
![[精品]C程序答案_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/5/970032c7-9b7d-44f0-8dd3-a153f9e5de12/970032c7-9b7d-44f0-8dd3-a153f9e5de122.gif)
![[精品]C程序答案_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/5/970032c7-9b7d-44f0-8dd3-a153f9e5de12/970032c7-9b7d-44f0-8dd3-a153f9e5de123.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、C程序答案以下程序如果是在Turbo C2.0運(yùn)行,請(qǐng)去掉“ voic?!?. #include<stdio.h>void fun(int &a,int &b)(int t;if(a>b)t=a;a=b;b=t;void mai n()(int a,b,c,d;prin tf("Please In put 3 n umbers:' n );scanf( % d%d%d,&a,&b,&c);fun( a,b);fun( a,c);fun (b,c);prin tf("The result is:n")
2、;printf( n%d %d %d” ,a,b,c);2. #i nclude <stdio.h> mai n()(char cl=C,c2=h,c3='i',c4=' n',c5='a'printf( n 原字符串是:%c%c%c%c%cn",cl,c2,c3,c4,c5); cl+=4; c2+=4;c3+=4;c4+=4;c5+=4;printf("密碼是:% c%c%c%c%cn",cl,c2,c3,c4,c5);3. #i nclude <stdio.h> void mai n()
3、(char ch;printf (” 請(qǐng)輸入一個(gè)字符n” ; scanf("%c",&ch);if (ch>='A'&&chv=Z)ch=ch+32;else if(ch>='a'&&chv='z') ch=ch-32; printf(H%cn n,ch);4. #i nclude<stdio.h>void mai n()(float a,b,t; pri ntf( “Please In put 2 n umbers:' n"); sea nf(
4、"%f%f', &a,&b);if(a>b)t=a;a=b;b=t;prin tf("%fn%f',a,b);5. #in clude<stdio.h>void mai n()int n,a,b,c,s;pr in tf("Please In put a n umber:' n"); sea nf("%d",&n);a=n%10;b=n/100;c=n/10-b*10;s=a+b+c;printf( nThe result is:nM);printf( n%dnn,s)
5、;6. #in clude<stdio.h>#in clude<math.h>float fun( float x)(float y;if(0>=x)return (y=sqrt(l_x);else if(x<=l)return (1-x);else return (y=pow(l-x),2);float main()float x,y;printf (”請(qǐng)輸入X的值:nn); sca nf("%f', &x);y=fu n( x); printf( n%fn,y);7. #in clude<stdio.h> float
6、 fun( float x)foaf y-ir(XAO)refurn (yulxxe-se refurn (y"2*x*x2=foaf maino宀foaf XMpzi.nffu B> X H±呼 rT scanr(=&f"cx yAun(x= prin=t(/fnw 9°琴 c-udecssiphv void maino 宀 infgj-mj-xr ror(gli-一込A-20 込 j+)(for(mli-rmA-33m+)(fodxli-wxA-1 oqxli-xj+3)ir(gj+mj+xjHH100)QOQO(gr5+mr3+xj、
7、3HH100)QOQO(gjvH_)QOQO(mjvll)QOQO(xjvH_) prin=t1 1 &d>n、k皚 &d H云 n-gjm-xj=0- #inc-ude Assiphvinf maino(inp-LKfor(z二 AU4 二+)(rowll二今4 二+)for(k"r kcu4- k+)iaHj)QO£Hk)QOQO0Hk)宀prin=t(=&d &d &dvrL j- k10. #i nclude <stdio.h>#i nclude <stdlib.h>#in elude <s
8、tri ng.h>#in elude <math.h>int main (void)int n = 0;printf (”請(qǐng)輸入一個(gè)正整數(shù)n” ;scanf("%d H, &n);if(n <0) printf (”輸入為負(fù)整數(shù),取絕對(duì)值求解n” ;n = -n;)if(n = 0 II n = 1 )printf("O和1不屬于質(zhì)數(shù)問題討論范圍。n”);return 0;if(n =2ll n= 3)printf( n%d 是質(zhì)數(shù))。nn, n);return 0;for(int i = 2; i<sqrt(n); i+)(if (
9、n % i) eon ti nue;printf( H%d 不是質(zhì)數(shù)。n” ,n);return 0;printf( H%d 是質(zhì)數(shù)。nn, n);return 0;11. #in elude <stdio.h> void mai n()int n=0;prin tf("i nput a stri ng:n"); while(getchar() !='n') n+; printf("The result is:n n); printf( n%dn n,n);12. #i nclude<stdio.h>void mai n()
10、int a10,b10,i;prin tf("Please In put 10 numbers:"); for(i=0;i< 10;i+)sca nf(H%dH,ai);for(i=5;i< 10;i+)bi=a10-i;for(i=0;i< 10;i+)printf(H%d%dn n,ai,bi);13. #i nclude <stdio.h>#defi ne N 10void mai n()(int aN,t,i;printf( n 請(qǐng)輸入 10 個(gè)數(shù):nn);for( i=0; i<N; i+ )scanf("%d n,&
11、amp;ai);printf ("交換前:n” ;for( i=0; i<N; i+ )printf( n%-5d n,ai);for( i=0; i<N/2; i+)(t=ai;ai=aN-i-l;aN-i-l=t;printf( nn 交換后:n” ;for( i=0; i<N; i+ )printf( H%-5d n,ai);14. #i nclude <stdio.h>void mai n()int i,j,t ; float a10;prin tf("Please In put the stude nt's scores:&q
12、uot;); for(i=0;i< 10;i+)sca nf("%f", &ai);for(j=0;j<9;j+)for(i=0;i<9J;i+)if(ai<ai+l)(t=ai;ai=ai+l;ai+l=t;)for(i=0;i< 10;i+) printf( H%fn n,ai);15. #in clude<stdio.h>#defi ne N 3typedef struct (char id8;int score 1;int score2;int score3;int sum; Stude nt;Student stu
13、dents N;Student input()(Stude nt stude nt;printf( nt 學(xué) 號(hào):”)seanf( %'s”,&student.id);pri ntf("tscorel:");sca nf("%d", &stude nt.scorel);pri ntf("tscore2:");sca nf("%d", &stude nt.score2);pri ntf("tscore3:");sca nf("%d", &
14、stude nt.score3);stude nt, sum = stude nt, score 1 +stude nt. score2+s tude nt. score3;retur n stude nt;int mai n()(int i=0,maxScore=0,i ndex=0;for(i=0;i<N ;i+)(printf (”輸入第 d個(gè)學(xué)生的信息:n” ,i+l);stude nts i = in put();if(stude ntsi.sum>maxScore)maxScore = stude ntsi.sum; in dex = i;printf("n 總分最高的是:%sn",studentsindex.id);printf("他的總分是:%d",maxScore);return 0;)16. #i nclude<s
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- DB50-T 1764-2024 渣海椒加工技術(shù)規(guī)范
- 本科教學(xué)工作審核評(píng)估宣傳手冊(cè)
- 病理學(xué)(醫(yī)學(xué)高級(jí)):病理學(xué)綜合強(qiáng)化練習(xí)題
- 《跨境電商實(shí)務(wù)》課件 項(xiàng)目二 比較跨境電商平臺(tái)
- 兒童哮喘的快速緩解與控制
- 湖南省三新協(xié)作體2024-2025學(xué)年高二下學(xué)期4月期中考試政治試題
- 廣東省韶關(guān)市2024-2025學(xué)年高一下學(xué)期期末教學(xué)質(zhì)量檢測(cè)生物試卷(無答案)
- 個(gè)性化教育與差異化教學(xué)
- 江西省贛州市2024-2025 學(xué)年高一下學(xué)期期末考試語(yǔ)文試卷(含答案)
- 少先隊(duì)活動(dòng)禮儀活動(dòng)方案
- 2025年陜西省中考數(shù)學(xué)試題(解析版)
- 黨課課件含講稿:《關(guān)于加強(qiáng)黨的作風(fēng)建設(shè)論述摘編》輔導(dǎo)報(bào)告
- GB/T 19023-2025質(zhì)量管理體系成文信息指南
- 多余物管理制度
- 2024北京朝陽(yáng)區(qū)三年級(jí)(下)期末語(yǔ)文試題及答案
- 灌腸技術(shù)操作課件
- 電梯維保服務(wù)投標(biāo)方案
- FMEA試題集(有標(biāo)準(zhǔn)規(guī)范答案)39709
- 關(guān)于“大學(xué)英語(yǔ)”課程免修免考的暫行規(guī)定
- 臥式雙面銑削組合機(jī)床的液壓系統(tǒng)設(shè)計(jì).
- 國(guó)家開發(fā)銀行山東省分行 簡(jiǎn)歷表
評(píng)論
0/150
提交評(píng)論