![[精品]C程序答案_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/5/970032c7-9b7d-44f0-8dd3-a153f9e5de12/970032c7-9b7d-44f0-8dd3-a153f9e5de121.gif)
![[精品]C程序答案_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/5/970032c7-9b7d-44f0-8dd3-a153f9e5de12/970032c7-9b7d-44f0-8dd3-a153f9e5de122.gif)
![[精品]C程序答案_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/5/970032c7-9b7d-44f0-8dd3-a153f9e5de12/970032c7-9b7d-44f0-8dd3-a153f9e5de123.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、C程序答案以下程序如果是在Turbo C2.0運行,請去掉“ voic。”1. #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 (” 請輸入一個字符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 (”請輸入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 (”請輸入一個正整數n” ;scanf("%d H, &n);if(n <0) printf (”輸入為負整數,取絕對值求解n” ;n = -n;)if(n = 0 II n = 1 )printf("O和1不屬于質數問題討論范圍。n”);return 0;if(n =2ll n= 3)printf( n%d 是質數)。nn, n);return 0;for(int i = 2; i<sqrt(n); i+)(if (
9、n % i) eon ti nue;printf( H%d 不是質數。n” ,n);return 0;printf( H%d 是質數。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 請輸入 10 個數: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 學 號:”)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個學生的信息: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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 筆墨紙硯試題及答案
- 包裝運輸試題及答案
- 產品推廣流程
- 2025年春節節前安全培訓
- 冷軋酸洗工藝流程
- 二甲醫院等級評審前培訓
- ICU病人腹瀉護理查房
- 小學音樂《愛我中華》課程
- 布藝銷售培訓
- 智齒拔除病例分析與微創拔牙技術應用
- 職業教育法考試題庫附完整答案【歷年真題】
- 2023-2024學年人教版數學八年級下冊 期末達標測試卷(四)
- 2024年河南能源集團有限公司招聘筆試沖刺題(帶答案解析)
- 500字作文標準稿紙A4打印模板-直接打印
- 高中數學《函數的概念及其表示》大單元專題教學設計
- 第09講醛酮(教師版)-高二化學講義(人教2019選擇性必修3)
- 巡回醫療工作總結
- 高血壓 糖尿病 健康宣教
- 國開電大軟件工程形考作業3參考答案
- 食堂檢查燃氣安全培訓記錄
- 湖南省長郡中學、雅禮中學等四校2024屆高一數學第二學期期末調研試題含解析
評論
0/150
提交評論