中央電大C語(yǔ)言程序設(shè)計(jì)模擬試題及解答(親測(cè))小抄參考_第1頁(yè)
中央電大C語(yǔ)言程序設(shè)計(jì)模擬試題及解答(親測(cè))小抄參考_第2頁(yè)
中央電大C語(yǔ)言程序設(shè)計(jì)模擬試題及解答(親測(cè))小抄參考_第3頁(yè)
中央電大C語(yǔ)言程序設(shè)計(jì)模擬試題及解答(親測(cè))小抄參考_第4頁(yè)
中央電大C語(yǔ)言程序設(shè)計(jì)模擬試題及解答(親測(cè))小抄參考_第5頁(yè)
已閱讀5頁(yè),還剩6頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、2012春電大c語(yǔ)言程序設(shè)計(jì)模擬試題及解答一、選擇題 1. 由c語(yǔ)言源程序文件編譯而成的目標(biāo)文件的缺省擴(kuò)展名為( c )。 a. cpp b. exe c. obj d. c 2. c語(yǔ)言程序的基本模塊為( d )。 a. 表達(dá)式 b. 標(biāo)識(shí)符 c. 語(yǔ)句 d. 函數(shù) 3. 設(shè)x和y均為邏輯值,則x|y為假的條件是( c )。 a它們均為真 b.其中一個(gè)為真 c.它們均為假 d.其中一個(gè)為假 4. x0 | y=5的相反表達(dá)式為( b )。a. x=0 | y!=5 b. x0 | y!=5 d. x0 & y=5 5. 枚舉類(lèi)型中的每個(gè)枚舉常量的值都是一個(gè)( a )。 a. 整數(shù) b. 浮點(diǎn)

2、數(shù) c. 字符 d. 邏輯值6. 循環(huán)體至少被執(zhí)行一次的語(yǔ)句為( c )循環(huán)語(yǔ)句。 afor b.while c.do-while d.任一種 7. 循環(huán)語(yǔ)句“for(int i=0; in; i+) s;”中循環(huán)體s被執(zhí)行的次數(shù)為( c )。 a. 1 b. n-1 c. n d. n+1 8. 在下面的while循環(huán)語(yǔ)句中,其循環(huán)體被執(zhí)行的次數(shù)為( c )。 int i=0,s=0; while(s3 & x10的相反表達(dá)式為 x=10 。 17若x=5,y=10,則x!=y的邏輯值為 1 。 18. 假定x=5,則執(zhí)行“int a=(! x? 10:20);”語(yǔ)句后a的值為 20 。19

3、. 在if語(yǔ)句中,每個(gè)else關(guān)鍵字與它前面同層次并且最接近的 if 關(guān)鍵字相配套。 20. 若while循環(huán)的“頭”為“while(i+name等價(jià)的表達(dá)式是 (*p).name 。三、寫(xiě)出下列每個(gè)程序運(yùn)行后的輸出結(jié)果 1. #include void main() int i, s=0; for(i=1;i+) if(s50) break; if(i%2=0) s+=i; printf(i,s=%d, %dn,i,s); 結(jié)果:i,s=15,56 2. #include void main() 結(jié)果* char ch=*; int i, n=5; while(1) for(i=0;in;i

4、+) printf(%c,ch); printf(n); if(-n=0) break; 3. #includeconst int n=5;void main()結(jié)果 1 1 1 2 2 2 3 6 9 4 24 33 int i,p=1,s=0; for(i=1;in;i+) p=p*i; s=s+p; printf(%5d%5d,i,p); printf(%5dn,s); 4. #include void main() int x=24,y=88; int i=2,p=1; do while(x%i=0 & y%i=0) p*=i; x/=i; y/=i; i+; while(x=i &

5、y=i); printf(%dn,p*x*y); 結(jié)果:p*x*y=8*3*11=264 5. #include void main() int a9=36,25,48,24,55,40,18,66,20; int i, b1, b2; a0=a1? (b1=a0, b2=a1):(b1=a1,b2=a0); for(i=2; i9; i+) if(aib1) b2=b1; b1=ai; else if(aib2) b2=ai; printf(%d %dn,b1,b2); 結(jié)果:18 20 6. #include void main() int a12=76,63,54,62,40,75,80

6、,92,77,84,44,73; int b4=60,70,90,101; int c4=0; int i,j; for(i=0;i=bj) j+; cj+; for(i=0;i4;i+) printf(%d,ci); printf(n); 結(jié)果:3 2 6 17. #include void main() int a=10, b=20;結(jié)果 10 20 40 35 40 20 printf(%d %dn,a,b); int b=a+25; a*=4; printf(%d %dn,a,b); printf(%d %dn,a,b); 8. #include void selectsort(int

7、 a, int n) int i,j,k,x; for(i=1;in;i+) /進(jìn)行n-1次選擇和交換 k=i-1; for(j=i;jn;j+) if(ajak) k=j; x=ai-1; ai-1=ak; ak=x; void main() int i; int a6=20,15,32,47,36,28; selectsort(a,6); for(i=0; i6; i+) printf(%d ,ai); printf(n); 結(jié)果:15 20 28 32 36 47 9#include void main() int a8=4,8,12,16,20,24,28,32; int *p=a;

8、do printf(%d,*p); p+=2; while(pa+8); printf(n); 結(jié)果:4 12 20 28 10. #include void le(int* a, int* b) int x=*a; *a=*b; *b=x; 結(jié)果15 26 26 15 void main() int x=15, y=26; printf(%d %dn,x,y); le(&x,&y); printf(%d %dn,x,y); 11. #include #include struct worker char name15; /姓名 int age; /年齡 float pay; /工資 ; in

9、t equal(struct worker* r1, struct worker* r2) if(strcmp(r1-name, r2-name)=0) return 1; else return 0; void main() struct worker a4=abc,25,420,defa,58,638, ghin,49,560,jklt,36,375; struct worker x=defa; int i; for(i=0; i=4) printf(沒(méi)有查找所需要的記錄!n); else printf(%s %d %6.2fn,,ai.age,ai.pay); 結(jié)果:def

10、a 58 638.00四、寫(xiě)出下列每個(gè)函數(shù)的功能 1. int se(int n) /n為大于等于1的整數(shù) int x,s=0; printf(輸入%d個(gè)整數(shù): ,n); scanf(%d,&x); if(n=1) return x; s=x; while(-n) scanf(%d,&x); s+=x; return s; 函數(shù)功能:求出鍵盤(pán)上輸入的n個(gè)整數(shù)之和并返回。2. float fh() float x,y=0,n=0;scanf(%f,%x);while(x! =-1.0) n+; y+=x;scanf(%f,%x);if(n-0) return y; else return y/n

11、; 函數(shù)功能:求出從鍵盤(pán)上輸出的一批常數(shù)的平均值,以-1.0作為結(jié)束輸入的標(biāo)志。 3. #include void wa(int a, int n) int i,k,j,x; for(i=0;in-1;i+) k=i; for(j=i+1;jak) k=j; x=ai; ai=ak; ak=x; 函數(shù)功能:采用選擇排序的方法對(duì)數(shù)組a中的n個(gè)整數(shù)按照從大到小的次序重新排列。 4. #include int* lj(int a, int n) int i,k=0; for(i=1;iak) k=i; return &ak; 函數(shù)功能:求出數(shù)組a中n個(gè)元素的最大值元素,返回該元素的地址。 5. vo

12、id qc(struct strnode* f) while(f) printf(%sn,f-name);f=f-next; 假定結(jié)構(gòu)類(lèi)型strnode的定義如下: stuct strnode char name15; /字符串域 struct strnode *next; /指針域 ; 函數(shù)功能:遍歷f單鏈表,即從頭結(jié)點(diǎn)開(kāi)始依次輸出f單鏈表中每個(gè)結(jié)點(diǎn)的值。 6. int output(struct intnode *f) int sum=0; if(!f) return -9999; /用返回特定值-9999表示空表 while(f) sum+=f-data; f=f-next; retur

13、n sum; 假定struct intnode的類(lèi)型定義為: struct intnode int data; /結(jié)點(diǎn)值域 struct intnode* next; /結(jié)點(diǎn)指針域 ; 函數(shù)功能:對(duì)于以表頭指針為f的鏈表,求出并返回所有結(jié)點(diǎn)中data域的值之和。 7. int wr4(file* fptr) char ch; int c=0; fseek(fptr,0,seek_set); while(1) ch=fgetc(fptr); if(ch!=eof) c+; else break; return c; 函數(shù)功能:求出一個(gè)以fptr為文件流的所對(duì)應(yīng)文件的長(zhǎng)度,即所存字符的個(gè)數(shù)。五、根

14、據(jù)下列每個(gè)題目要求編寫(xiě)程序1. 編寫(xiě)一個(gè)函數(shù)fun(),首先從鍵盤(pán)上輸入一個(gè)4行4列的一個(gè)實(shí)數(shù)矩陣到一個(gè)二維數(shù)組a44中,接著求出主對(duì)角線上元素之和,最后返回求和結(jié)果。 #include double fun() double a44; double s=0; int i,j; printf(輸入一個(gè)4*4的數(shù)值矩陣:n); for(i=0;i4;i+) for(j=0;j4;j+) scanf(%lf,&aij); for(i=0;i4;i+) s+=aii;i return s; void main() printf(主對(duì)角線上元素之和是%lfn,fun(); 2. 編寫(xiě)一個(gè)主函數(shù),計(jì)算1

15、+3+32+.+310的值并輸出,假定分別用i,p,s作為循環(huán)變量、累乘變量和累加變量的標(biāo)識(shí)符。#include void main() int i; /用i作為循環(huán)變量 int p=1; /用p作為累乘變量 int s=1; /用s作為累加循環(huán)變量 for(i=1;i=10;i+) p*=3; s+=p; printf(%dn,s); 3. 編寫(xiě)一個(gè)主函數(shù),已知6a40,15b30,求出滿(mǎn)足不定方程2a+5b=120的全部整數(shù)組解。如(13,20)就是其中的一組解。#include void main() int a,b; for(a=6;a=40; a+) for(b=15;b=30;b+

16、) if(2*a+5*b=126) printf(%d, %d)n,a,b); if we dont do that it will go on and go on. we have to stop it; we need the courage to do it.his comments came hours after fifa vice-president jeffrey webb - also in london for the fas celebrations - said he wanted to meet ivory coast international toure to di

17、scuss his complaint.cska general director roman babaev says the matter has been exaggerated by the ivorian and the british media.blatter, 77, said: it has been decided by the fifa congress that it is a nonsense for racism to be dealt with with fines. you can always find money from somebody to pay th

18、em.it is a nonsense to have matches played without spectators because it is against the spirit of football and against the visiting team. it is all nonsense.we can do something better to fight racism and discrimination.this is one of the villains we have today in our game. but it is only with harsh

19、sanctions that racism and discrimination can be washed out of football.the (lack of) air up there watch mcayman islands-based webb, the head of fifas anti-racism taskforce, is in london for the football associations 150th anniversary celebrations and will attend citys premier league match at chelsea

20、 on sunday.i am going to be at the match tomorrow and i have asked to meet yaya toure, he told bbc sport.for me its about how he felt and i would like to speak to him first to find out what his experience was.uefa hasopened disciplinary proceedings against cskafor the racist behaviour of their fans

21、duringcitys 2-1 win.michel platini, president of european footballs governing body, has also ordered an immediate investigation into the referees actions.cska said they were surprised and disappointed by toures complaint. in a statement the russian side added: we found no racist insults from fans of

22、 cska.baumgartner the disappointing news: mission aborted.the supersonic descent could happen as early as sunda.the weather plays an important role in this mission. starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud co

23、ver. the balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. it will climb higher than the tip of mount everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (

24、5.6 miles/9.17 kilometers) and into the stratosphere. as he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.the balloon will slowly drift to the edge of space at 120,000 feet ( then, i would assume, he will slowly step out onto something resembling an olympic divi

25、ng platform.below, the earth becomes the concrete bottom of a swimming pool that he wants to land on, but not too hard. still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. it will be like he is diving into the shallow end.skydiver preps for the big jumpwhen he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds.

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 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ì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論