




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、三、給出下列程序運行后的輸出結果 1. #include void main() int s=0; for(int i=1;i+) if(s50) break; if(i%2=0) s+=i; couti,s=i,sendl; 2. #include void main() char a=abcdabcabfgacd; int i1=0, i2=0, i=0; while(ai) if(ai=a) i1+; if(ai=b) i2+; i+; couti1 i2endl; 3. #include void main() int a9=2,4,6,8,10,12,14,16,18; for(in
2、t i=0;i9;i+) coutsetw(5)*(a+i); if(i+1)%3=0) coutendl; 4. #include void le(int* a, int* b) int x=*a; *a=*b; *b=x; cout*a *bendl; void main() int x=10, y=25; le(&x,&y); coutx yendl; 5. #include class a int a,b; public: a() a=b=0; a(int aa, int bb) a=aa; b=bb; couta bendl; ; void main() a x,y(2,3),z(4
3、,5); 6#include template class ff tt a1, a2, a3; public: ff(tt b1, tt b2, tt b3) a1=b1; a2=b2; a3=b3; tt sum() return a1+a2+a3; ; void main() ff x(2,3,4),y(5,7,9); coutx.sum() y.sum()endl; 7. #include void sb(char ch) switch(ch) case a: case a: coutwell!;break; case b: case b: coutgood!;break; case c
4、: case c: coutpass!;break; default: coutbad!;break; void main() char a1=b,a2=c,a3=f; sb(a1);sb(a2);sb(a3);sb(a); coutendl; 8. #include #include void main() char* a5=student,worker,cadre,soldier,peasant; char *p1, *p2; p1=p2=a0; for(int i=0;i0) p1=ai; if(strcmp(ai, p2)0) p2=ai; coutp1 p2endl; 9. #inc
5、lude int a=5; void main() int a=10, b=20; couta bendl; int a=0,b=0; for(int i=1; i6; i+) a+=i; b+=a; couta b :aendl; couta bendl; 10. #include int lb(int *a, int n) int s=1; for(int i=0;in;i+) s*=*a+; return s; void main() int a=1,2,3,4,5,6,7,8; int b=lb(a,5)+lb(&a3,3); coutb=bendl; 11. #include #in
6、clude struct worker char name15; /姓名 int age; /年齡 float pay; /工資 ; void main() worker x; char *t=liouting; int d=38; float f=493; strcpy(,t); x.age=d; x.pay=f; x.age x.payendl; 12. #include class a int a; public: a(int aa=0) a=aa; a() coutdestructor a!aendl; ; class b: public a int
7、b; public: b(int aa=0, int bb=0): a(aa) b=bb; b() coutdestructor b!bendl; ; void main() b x(5), y(6,7); /后定義的變量將先被釋放 三、給出下列程序運行后的輸出結果1. i,s=15,562. 4 33. 2 4 6 8 10 12 14 16 184. 25 10 25 105. 2 3 4 56. 9 217. good!pass!bad!well!8. worker cadre9. 10 20 15 35 5 10 2010. b=24011. liouting 38 49312. de
8、structor b!7 destructor a!6 destructor b!0 destructor a!5三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include void main() int n=5, sum=0; while(n0) sum+=n; n-; coutsum=sumendl; 運行結果: 2. #include const int n=6; void main() int an=76,83,54,62,40,65; int max=a0; for(int i=1;imax) max=ai; coutmax=maxendl; 運行結果: 3
9、. #include void main() int a8=4,8,15,16,20,30,48,62; int *p=a, s=0; while(pa+8) s+=*p; p+=3; coutsendl; 運行結果: 4.#include int lf(int x, int y) x=x+y; y=x+y; return x+y; void main() int x=2, y=3; coutlf(x,y)endl; 運行結果: 5. #include class a int a,b; public: a() a=b=0; a(int aa, int bb) a=aa; b=bb; int s
10、um()return a+b; ; void main() a x,y(3,4); coutx.sum() y.sum()endl; 運行結果:三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. sum=152. max=833. 684. 135. 0 7 /每個數(shù)據(jù)3分三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include #include int sd(int a, int b, char op) switch(op) case +: return a+b; case -: return a-b; default: cout操作符op出錯,退出
11、運行!;exit(1); void main() int x=20, y=6; coutsd(x,y,+) sd(x,y,-)endl; 運行結果: 2. #include #include void main() char* a5=student,worker,cadre,soldier,apen; char *p1; p1=a0; for(int i=1;i0) p1=ai; coutp1endl; 運行結果: 3. #include int wf(int x, int y) x=x+y;x=13; y=x+y;y=13+5=18; return x+y; void main() cout
12、wf(8,5)endl; 運行結果: 4. #include const int n=9; void main() int an=2,4,6,8,10,12,14,16,18; int s=0; for(int i=0; in; i+) if(i%3=0) s+=ai; cout”s=”sendl; 運行結果: 5. #include void main() int* d=new int5; int i; for(i=0;i5;i+) di=2*i+1; coutdi ; coutendl; deleted; 運行結果:三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. 26 1
13、4 /每個數(shù)據(jù)3分2. worker3. 314. 245. 1 3 5 7 9 /每個數(shù)據(jù)1分,全對給6分三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include void main() int n=5, sum=0; while(n) sum+=n; n-; cout”sum=”sumendl; 運行結果: 2. #include const int n=6; void main() int an=76,83,54,62,40,65; int c1, c2; c1=c2=a0; for(int i=1;ic1) c1=ai; else if(aic2) c2=a
14、i; coutc1 c2endl; 運行結果: 3. #include void main() int a8=4,8,15,16,20,30,48,62; int *p=a; do cout*p ; p+=3; while(pa+8); coutendl; 運行結果: 4.#include int lf(int x, int y) x=x+y; y=x+y; return x+y; void main() int x=5, y=8; coutlf(x,y) lf(10,6)endl; 運行結果: 5. #include class a int a,b; public: a() a=b=0; a
15、(int aa, int bb) a=aa; b=bb; couta bendl; ; void main() a x,y(2,3); 運行結果:三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. sum=152. 83 40 /每個數(shù)據(jù)3分3. 4 16 48 /每個數(shù)據(jù)2分4. 34 38 /每個數(shù)據(jù)3分5. 2 3 /每個數(shù)據(jù)3分三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include void sb(char ch) switch(ch) case a: case a: cout優(yōu)! ; break; case b: case b: cout良
16、! ; break; case c: case c: cout通過! ; break; default: cout不通過!;break; void main() sb(a); sb(c); coutendl; 運行結果: 2. #include void main() int a6=36,25,48,14,55,40; int x=a0; for(int i=1;ix) x=ai; cout”x=”xendl; 運行結果: 3. #include void main() int a6=32,53,27,19,12,45; for(int *p=a; pa+6; p+) if(*p%3=0) c
17、out*p ; coutendl; 運行結果: 4. #include int* lg(int m) int* a=new int(m+5); return a; void main() int n1=12; int *b=lg(n1); cout*bendl; delete b; 運行結果: 5. #include #include struct worker char name15; int age; float pay; ; void main() worker x; strcpy(, weirong); x.age=45; x.pay=3275; x.
18、age x.payendl; 運行結果:三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. 優(yōu)! 通過! /每個數(shù)據(jù)占3分2. x=553. 27 12 45 /每個數(shù)據(jù)占2分4. 175. weirong 45 3275三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include void main() int n=4,y=1; while(n-) y*=3; couty=yendl; 運行結果: 2. #include void main() int a8=2,8,10,5,12,7,9,20; int c=0, i=0; while(i10) c+;
19、 i+; coutc=cendl; 運行結果:c=2 3. #include void main() int a5=3,6,9,12,8; for(int *p=a; p8) cout*p ; 運行結果:9 12 4. #include int la(int a, int n) int s=0; for(int i=0;in;i+) s+=ai; return s; void main() int a5=5,2,8,6,4; int b=la(a,5); coutb=bendl; 運行結果:b=25 5. #include struct ab char aa15; int bb; ; void
20、 main() ab a4=apple,25,peach,40,pear,36,tomato,62; for(int i=0;i4;i+) if(ai.bb40) coutai.aa ; coutendl; 運行結果:三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. y=812. c=23. 9 124. b=255. apple pear三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #includevoid main()int n=4,y=1;while(n-) y*=3;couty=yendl; 運行結果:y=81 2. #includevoid ma
21、in()int a8=2,8,10,5,12,7,9,20;int c=0,i=0;while(i8)if(ai10) c+;i+;coutc=cendl; 運行結果:c=5 3.#includevoid main()int a5=3,6,9,12,8;for(int *p=a;i10) cout*pendl; 運行結果:12 4. #includeint la(int a,int n)int s=0;for(int i=0;in;i+)s+=ai;return s;void main()int a5=5,2,8,6,4;int b=la(a,5);coutb=bendl; 運行結果:b=25
22、 5. #includestruct abchar a15;int bb;void main()ab a4=apple,25,peach,40,pear,36,tomato,62;for(int i=0;i=40) coutai.aa ;coutendl; 運行結果:peach tomato三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. y=812. c=53. 124. b=255. pear tomato三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include void main() int n=5, sum=0; while(n) sum+=
23、n*n; n-; coutsum=sumendl; 運行結果: 2. #include const int n=6; void main() int an=76,83,54,62,40,65; int c1=0; for(int i=0;i=60) c1+; coutc1=c1endl; 運行結果: 3. #include void main() int a8=4,8,15,16,20,30,48,62; int *p=a,s=0; while(pa+8) s+=*p; p+=3; coutsendl; 運行結果: 4. #include int a=10, b=15, c; void mai
24、n() c=a+b; int b=a+20; c+=a+b; coutcendl; 輸出結果: 5. #include void ff(int a, int n) int i,x; for(i=0; in/2; i+) x=ai; ai=an-1-i; an-1-i=x; void main() int a8=6,19,4,12,20,5,18,25; ff(a,8); couta0,a1endl; 輸出結果:三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. sum=552. 4 3. 68 4. 655. 25,18三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)
25、 1. #include void main() int n=5, sum=0; while(n) sum+=n; n-; cout”sum=”sumendl; 運行結果: 2. #include const int n=6; void main() int an=76,83,54,62,40,65; int c1, c2; c1=c2=a0; for(int i=1;ic1) c1=ai; else if(aic2) c2=ai; coutc1 c2endl; 運行結果: 3. #include void main() int a8=4,8,15,16,20,30,48,62; int *p
26、=a; while(pa+8) cout*p ; p+=3; coutendl; 運行結果: 4.#include int lf(int x, int y) x=x+y; y=x+y; return x+y; void main() int x=5, y=8; coutlf(1,2) lf(3,4)endl; 運行結果: 5. #include class a int a,b; public: a() a=b=0; a(int aa, int bb) a=aa; b=bb; couta bendl; ; void main() a x,y(3,4); 運行結果:三、寫出下列每個程序運行后的輸出
27、結果(每小題6分,共30分)1. sum=152. 83 40 /每個數(shù)據(jù)3分3. 4 16 48 /每個數(shù)據(jù)2分4. 8 18 /每個數(shù)據(jù)3分5. 3 4 /每個數(shù)據(jù)3分三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include void main() int s=0; for(int i=1;i=8;i+=2) s+=i*i; couts=sendl; 輸出結果: 2. #include void main() int i=1,s=0; while(s15) s+=i+; couti,sendl; 輸出結果: 3. #include void main() int
28、 a8=36,25,48,14,55,20,47,82; int c1=0, c2=0; for(int i=0; i8; i+) if(ai50) c1+; else c2+; coutc1 c2endl; 輸出結果: 4. #include int lb(int *a, int n) int p=1; for(int i=0;in;i+) p*=*a; a+; return p; void main() int a5=1,2,3,4,3; coutlb(a,5)endl; 輸出結果: 5. #include struct worker char name15; /姓名 int age; /
29、年齡 float pay; /工資 ; void main() worker x=wangfong,46,1640; worker y, *p; y=x; p=&x; couty.age+10 pay*2endl; 輸出結果:三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分)1. s=842. 6,15 /每個數(shù)據(jù)3分3. 6 2 /每個數(shù)據(jù)3分4. 72 /6分5. 56 3280 /每個數(shù)據(jù)3分三、寫出下列每個程序運行后的輸出結果(每小題6分,共30分) 1. #include void main() int s1=0, s2=1; for(int i=1; i=6; i+) s1+=i; s2*=i; couts1,s2endl; 輸出結果: 2. #include void main() int a10=68,79,86,65,46,94,37,78,60,53; int c=0; for(int i=0;i=60) c+; cout”c=”cendl; 輸出結果: 3. #include void main() int a34=1,2,7,8,5,6,11,15,9,20,3,4; int m=a
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 設備運輸方案模板 (一)
- 國家開放大學《教育心理學》形考任務1-4答案
- 設計基礎教案
- 幼兒園大班《樹真好》活動教案
- 財務會計人員的崗位職責(25篇)
- 2025年Android小菜雞2 個月的面試親身經(jīng)歷告訴大家如何進入 BAT 等大廠
- 2024-2025學年下學期高二生物滬科版期末必刷??碱}之生態(tài)系統(tǒng)具有維持動態(tài)平衡的能力
- 森林報春的題目及答案
- 2023-2024學年山東省煙臺市高二下學期7月期末學業(yè)水平診斷數(shù)學試題(解析版)
- 2023-2024學年湖南省邵陽市高二下學期期末考試數(shù)學試卷(解析版)
- 人力資源薪酬專員個人月工作計劃
- 期末考試(試題)-2023-2024學年五年級下冊數(shù)學人教版
- 乳腺癌病人的心理護理課件
- 2024年茶葉加工工(高級)理論考試題庫大全(附答案)
- 大連公交集團管理制度
- ABAQUS在隧道及地下工程中的應用
- 林業(yè)和草原建設項目初步設計編制實施細則
- 醫(yī)療安全不良事件培訓
- 機器人結構優(yōu)化設計
- 員工能力評價表(全套)
- 土石方工程挖掘機人員車輛信息登記表
評論
0/150
提交評論