




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、第四章單選有以下程序 ,程序運行后的輸出結(jié)果是( ) #include int fun (int x,int y) if (x!=y) return (x+y)/2); else return (x); int main() int a=4,b=5,c=6; printf(%dn,fun(2*a,fun(b,c); return 0; a.12 b.6c.3 d.8 有以下程序 ,程序運行的輸出結(jié)果 ( ) #include int f(int x); int main() int n=1,m; m=f(f(f(n); printf(“%dn”,m);return 0 ; int f(int
2、x) return x*2; a.8 b.4c.1d.2 有以下程序 ,程序執(zhí)行后變量w 中的值是 ( ) #include int funl(double a)return a*=a; int fun2(double x,double y) double a=0,b=0; a=funl(x);b=funl(y);return (int)(a+b); int main() double w;w=fun2(1.1,2.0);a.5.21 b.0.0 c.5.0d.5 有以下程序 , 程序運行后的輸出結(jié)果是()#include int fun() static int x=1; x*=2; ret
3、urn x; 精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 1 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 1 頁,共 10 頁 - - - - - - - - - int main() int i,s=1; for(i=1;i=3;i+) s*=fun(); printf(%dn,s); a.10 b.64 c.0 d.30 有以下程序 , 程序運行后的輸出結(jié)果是()#include int f(int x,int y) return (y-x)*
4、x); int main() int a=3,b=4,c=5,d; d=f(f(a,b),f(a,c); printf(%dn,d); a.10 b.8 c.7 d.9 有以下程序 , 程序運行后的輸出結(jié)果是()#include void fun(int p) int d=2; p=d+; printf(“ %d ” ,p); int main() int a=1; fun(a); printf(“ %dn” ,a); return 0; a.22 b.21 c.12 d.32 有以下程序:程序運行后的輸出結(jié)果是( ) #include int f() static int x=1; x+=1
5、; return x; int main() 精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 2 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 2 頁,共 10 頁 - - - - - - - - - int i,s=1; for(i=1;i=5;i+) s+=fun(); printf(%dn,s); return 0; a.21 b.6c.120d.11 若有代數(shù)式|xxen ( 其中e僅代表自然對數(shù)的底數(shù),不是變量) ,則以下能夠正確表示該代數(shù)式的
6、 c語言表達(dá)式是()a.sqrt(fabs(pow(n,x)+exp(x,e) b.sqrt(fbs(pow(n,x)+pow(x,e) c.sqrt(fabs(pow(x,n)+exp(x) d.sqrt(abs(nx+ex) 以下關(guān)于 return 語句敘述中正確的是()a.定義void 類型的函數(shù)中可以有帶返回值的return 語句b.沒有return 語句的自定義函數(shù)在執(zhí)行結(jié)束時不能返回到調(diào)用處c.一個自定義函數(shù)中必須有一條return 語句d.一個自定義函數(shù)中可以根據(jù)不同情況設(shè)置多條return 語句設(shè)有如下函數(shù)定義 , 若執(zhí)行調(diào)用語句: n=fun(3);,則函數(shù) fun 總共被調(diào)
7、用的次數(shù)是( ) int fun(int k) if (k1) return 0; else if(k=1) return 1; else return fun(k-1)+1; a.2 b.3 c.5 d.4 在一個 c語言源程序文件中所定義的全局變量,其作用域為()a.所在函數(shù)的全部范圍b.所在文件的全部范圍c.由具體定義位置和 extern 說明來決定范圍d.所在程序的全部范圍以下敘述正確的是()a.c語言函數(shù)可以嵌套調(diào)用,例如:fun(fun(x) b.c語言程序是由過程和函數(shù)組成的c.c語言函數(shù)不可以單獨編譯d.c語言中除了 main函數(shù),其他函數(shù)不可以作為單獨文件形式存在以下程序的主
8、函數(shù)中調(diào)用了在其前面定義的fun 函數(shù), 則以下選項中錯誤的 fun 函精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 3 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 3 頁,共 10 頁 - - - - - - - - -數(shù)首部是 ( ) #include int main() double a15,k; k=fun(a); return 0; a.double fun(double *a) b.double fun(double a) c.doub
9、le fun(double a) d.double fun(double a15) 以下說法不正確的是()a.系統(tǒng)不允許用戶重新定義標(biāo)準(zhǔn)庫函數(shù)b.標(biāo)準(zhǔn)庫函數(shù)按分類在不同的頭文件中聲明c.用戶可以重新定義標(biāo)準(zhǔn)庫函數(shù)d.用戶若需要調(diào)用標(biāo)準(zhǔn)庫函數(shù), 調(diào)用前必須使用預(yù)編譯命令將該函數(shù)所在文件包括到用戶源文件中下列敘述中正確的是()a.c語言規(guī)定必須用 main作為主函數(shù)名,程序?qū)拇碎_始執(zhí)行,在此結(jié)束b.main可作為用戶標(biāo)識符,用以命名任意一個函數(shù)作為主函數(shù)c.可以在程序中由用戶指定任意一個函數(shù)作為主函數(shù),程序?qū)拇碎_始執(zhí)行d.c語言程序?qū)脑闯绦蛑械谝粋€函數(shù)開始執(zhí)行若函數(shù)調(diào)用時的實參為變量時, 以
10、下關(guān)于函數(shù)形參和實參的敘述中正確的是()a.同名的實參和形參占同一存儲單元b.函數(shù)的形參和實參分別占用不同的存儲單元c.函數(shù)的實參和其對應(yīng)的形參共占同一存儲單元d.形參只是形式上的存在,不占用具體存儲單元在c 語言中,只有在使用時才占用內(nèi)存單元的變量,其存儲類型是() 。a.extern 和register b.auto 和register c.static和register d.auto 和 static 設(shè)函數(shù)中有整形變量 n,為保證其在未賦初值的情況下初值為0,應(yīng)該選擇的存儲類別是()a.register b.auto 精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - -
11、- - - - - 第 4 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 4 頁,共 10 頁 - - - - - - - - -c.auto 或register d.static 以下正確的函數(shù)定義形式是: ( )a.double fun(int x,int y) b.double fun(int x, y); c.double fun(int x ;int y) d.double fun(int x,int y); 在函數(shù)調(diào)用過程中,如果函數(shù) funa調(diào)用了函數(shù) funb, 函數(shù)funb又調(diào)用
12、了函數(shù) funa,則 ()a.稱為函數(shù)的循環(huán)調(diào)用b.c語言中不允許這樣的遞歸調(diào)用c.稱為函數(shù)的間接遞歸調(diào)用d.稱為函數(shù)的直接遞歸調(diào)用程序設(shè)計/* 請編寫函數(shù) fun,其功能是 : 將所有大于 1小于整數(shù) m的非素數(shù)存入xx 所指數(shù)組中 , 非素數(shù)的個數(shù)通過 k 傳回。例如 , 輸入 17, 則應(yīng)輸出 4 6 8 9 10 12 14 15 16。注意 : 部分源程序給出如下。請勿改動 main 函數(shù)和其他函數(shù)中的任何內(nèi)容, 僅在函數(shù) fun 的花括號中填入所編寫的若干語句。試題程序 : */ #include #include #include int fun(int m, int xx) /
13、*begin*/ /* end */ int main() file *wf; int m, n, zz100; printf(nplease enter an integer number between 10 and 100: ); scanf(%d,&n); m=fun(n,zz); printf(nnthere are %d non-prime numbers less than %d: ,m,n); for(n=0;nm;n+) printf(%4dn,zzn); wf=fopen(debugout.dat,w); 精品學(xué)習(xí)資料 可選擇p d f - - - - - - -
14、- - - - - - - 第 5 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 5 頁,共 10 頁 - - - - - - - - - m=fun(21,zz); for(n=0;nm;n+) fprintf(wf,%dn,zzn); fclose(wf); return 0; 【參考代碼】 int i,k,j=0; for(i=2;im;i+) for(k=2;ki;k+) if(i%k=0) break; if(ki) xxj+=i; return j; 程序改錯/* 下列給定程序中, 函
15、數(shù) fun 的功能是 : 將十進(jìn)制正整數(shù)m轉(zhuǎn)換成(29)kk進(jìn)制數(shù) , 并按位輸出。例如 , 若輸入 8和2, 則應(yīng)輸出 1000( 即十進(jìn)制數(shù) 8轉(zhuǎn)換成二進(jìn)制表示是1000) 。請改正函數(shù) fun 中的錯誤 , 使它能得出正確的結(jié)果。注意 : 不要改動 main 函數(shù) , 不得增行或刪行, 也不得更改程序的結(jié)構(gòu)。試題程序 :*/ #include #include /*error*/ void fun(int m,int k); int aa20, i; for(i=0;m;i+) /*error*/ aai=m/k; m/=k; for(;i;i-) /*error*/ printf(%d
16、,aai); int main() int b,n; 精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 6 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 6 頁,共 10 頁 - - - - - - - - - printf(nplease enter a number and a base:n); scanf(%d%d,&n,&b); fun(n,b); printf(n ); return 0; 【參考答案】void fun(int m
17、, int k) 【參考答案】aai=m%k; 【參考答案】printf(%d, aai-1); 如當(dāng) n的值為 20 時, 該數(shù)列為 3,8,13,18,23,28,93,98。符合此條件的累加值應(yīng)為42,126,366,570,1010。請改正程序中的錯誤, 使它能得出正確的結(jié)果。注意 : 不要改動 main 函數(shù) , 不得增行或刪行, 也不得更改程序的結(jié)構(gòu)。試題程序 : */ #include #define n 20 int fun(int n, int a) /*error*/ int i,j,k,sum; sum=0; for(k=3,i=0;in;i+,k+=5) sum=sum
18、+k; /*error*/ if(sum%4=2) aj+=sum; /*error*/ return j-1; int main() int an,d,n,i; printf(nenter n(4=n=50): ); scanf(%d,&n); d=fun(n,a); printf(nnthe result :n ); for(i=0;id;i+) printf(%6d ,ai); printf(nn ); return 0; 精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 7 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資
19、料 可選擇p d f - - - - - - - - - - - - - - 第 7 頁,共 10 頁 - - - - - - - - -【參考答案】int i,j=0,k,sum;【參考答案】if(sum%4=2) 【參考答案】return j+; return j; /* 下列給定程序中,函數(shù) fun 的功能是 :計算函數(shù) f(x,y,z)=(x+y)/(x-y)+(z+y)/(z-y)的值。其中 x和y不相等 ,z 和y不等。例如 , 當(dāng)x的值為 9,y 的值為 11,z 的值為 15時, 函數(shù)值為 -3.50 。請改正程序中的錯誤, 使它能得出正確的結(jié)果。注意 : 不要改動 main函
20、數(shù) , 不得增行或刪行, 也不得更改程序的結(jié)構(gòu)。試題程序 :*/ #include #include #include /*error*/ #define fu(m,n) (m/n) float fun(float a,float b,float c) float value; value=fu(a+b,a-b)+fu(c+b,c-b); /*error*/ return(value); void main() float x,y,z,sum; printf(input x y z: ); scanf(%f%f%f,&x,&y,&z); printf(x=%f,y=%f
21、,z=%fn ,x,y,z); if(x=y|y=z) printf(data error! n ); exit(0); sum=fun(x,y,z); printf(the result is:%5.2fn ,sum); 【參考答案】#define fu(m,n) (m)/(n) #define fu(m,n) (m)/(n) 【參考答案】return(value); return value; 精品學(xué)習(xí)資料 可選擇p d f - - - - - - - - - - - - - - 第 8 頁,共 10 頁 - - - - - - - - -精品學(xué)習(xí)資料 可選擇p d f - - - - -
22、 - - - - - - - - - 第 8 頁,共 10 頁 - - - - - - - - -/* 下列給定程序中,函數(shù) fun 的功能是 :按如下遞歸公式求函數(shù)值。10(1)fun(n)=(1)2(1)nfun nn例如 , 當(dāng)給 n輸入 5時, 函數(shù)值為 18; 當(dāng)給 n輸入 3時, 函數(shù)值為 14。請改正程序中的錯誤, 使它能得出正確的結(jié)果。注意 : 不要改動 main函數(shù) , 不得增行或刪行, 也不得更改程序的結(jié)構(gòu)。試題程序 : */ #include /*error*/ int fun(n) int c; /*error*/ if(n=1) c=10; else c=fun(n-
23、1)+2; return(c); void main() int n; printf(enter n: ); scanf(%d,&n); printf(the result: %dnn ,fun(n); 【參考答案】int fun(int n) 【參考答案】if(n=1) if(1=n) /* 下列給定程序中,函數(shù) fun 的功能是 :用遞歸算法計算斐波拉契級數(shù)列中第n項的值。從第一項起 , 斐波拉契級數(shù)序列為1,1,2,3,5,8,13,21,例如 ,若給 n輸入 7, 該項的斐波拉契級數(shù)值為 13。請改正程序中的錯誤, 使它能得出正確的結(jié)果。注意 : 不要改動 main函數(shù) , 不得增行或刪行, 也不得更改程序的結(jié)構(gòu)。試題程序 :*/ #include long fun(int g) /*error*/ 精品學(xué)習(xí)資料 可選擇p d f - - -
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 主管在企業(yè)轉(zhuǎn)型中的角色定位計劃
- 提高財務(wù)規(guī)劃準(zhǔn)確性的策略計劃
- 生物學(xué)科德育滲透計劃
- 社區(qū)服務(wù)交流計劃
- 學(xué)校社團(tuán)與社會的聯(lián)系計劃
- 2025年Γ-球蛋白三類項目建議書
- 2025年垃圾分類項目發(fā)展計劃
- 2025年青霉素類抗菌藥物項目建議書
- 關(guān)于提升工作效率的內(nèi)部培訓(xùn)通知
- 高中生數(shù)學(xué)思維訓(xùn)練故事解讀
- 2022年北京海淀區(qū)高三一模物理試題和答案
- 施工工法的編寫與申報(完整版)
- 歇后語大全500條
- 學(xué)前兒童表演游戲的組織與指導(dǎo)(學(xué)前兒童游戲課件)
- 中小學(xué)教師校園安全培訓(xùn)
- 2024年北京法院聘用制審判輔助人員招聘筆試參考題庫附帶答案詳解
- 建筑用真空陶瓷微珠絕熱系統(tǒng)應(yīng)用技術(shù)規(guī)程
- (高清版)DZT 0276.13-2015 巖石物理力學(xué)性質(zhì)試驗規(guī)程 第13部分:巖石比熱試驗
- (高清版)DZT 0214-2020 礦產(chǎn)地質(zhì)勘查規(guī)范 銅、鉛、鋅、銀、鎳、鉬
- (高清版)DZT 0017-2023 工程地質(zhì)鉆探規(guī)程
- 華為狼性培訓(xùn)課件
評論
0/150
提交評論