




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、專業(yè)好文檔計算機應用專業(yè)“c+語言程序設計”課程作業(yè)第一次作業(yè)一、填空題1c+語言中的每條基本語句以 ; 作為結(jié)束符,每條復合語句以 作為結(jié)束符。2用于輸出表達式值的標準輸出流對象是 cout ,用于從鍵盤上為變量輸入值的標準入流對象是 cin 。3當不需要函數(shù)返回任何值時,則應把該函數(shù)類型定義為 void 。4執(zhí)行“cout143+18=143+18endl;”語句后得到的輸出結(jié)果為 143+18=161 。5執(zhí)行“cout“ning”“chen”38endl;”語句后得到的輸出結(jié)果為 ningchen38 。6在每個c+程序中都必須包含有這樣一個函數(shù),該函數(shù)的函數(shù)名為 main 。7c+源
2、程序文件的缺省擴展名為 cpp ,由c+源程序文件編譯而成的目標文件的缺省擴展名為 obj ,由c+目標文件連接而成的可執(zhí)行文件的缺省擴展名為 exe 。8程序運行中需要從鍵盤上輸入多于一個數(shù)據(jù)時,各數(shù)據(jù)之間應使用 空格 或 逗號 符號作為分隔符。9十進制數(shù)25表示成符號c+語言規(guī)則的八進制和十六進制數(shù)分別為 31 和 19 符號。10在c+語言中,用轉(zhuǎn)義字符序列 n 或操縱符 endl 表示輸出一個換行符。11執(zhí)行“coutchar(b+2)endl;”語句后得到的輸出結(jié)果為 d 。12執(zhí)行“coutchar(k-3)endl;”語句后得到的輸出結(jié)果為 h 。13已知az的ascii碼為65
3、90,當執(zhí)行“int x=h+5;”語句后x的值為 77 。14已知az的ascii碼為6590,當執(zhí)行“char ch=16*5+2;coutchendl;語句序列后,得到的輸出結(jié)果為 r 。15假定一個枚舉類型的定義為“enum raxa,xb,xc,xd;”,則執(zhí)行“cout”xc=”xcendl;”語句得到的輸出結(jié)果為 xc=2 。16假定一個枚舉類型的定義為“enum rbab,ac=3,ad,aex=ad;”則x的值為 4 。17char、short和int類型的大小分別為 1字節(jié) 、 2字節(jié) 和 4字節(jié) 。18float和double類型的大小分別為 4字節(jié) 和 8字節(jié) 。19十
4、進制數(shù)128和-3.26的類型分別為 整型 和 雙精度型 。20若需要定義一個標識符常量,并且使c+能夠進行類型檢查,則應在定義語句的開始用保留字 define 。21使用const語句定義一個標識符常量時,則必須對它同時進行 初始化 。22執(zhí)行“int x=45,y=16;coutx/yx%yz的相反表達式為 x+y5& x10的相反表達式 x=10 。34邏輯表達式ab | | b= =5的相反表達式為 ay 和x=y的邏輯值分別為 false 和 true 。36假定x=5,則執(zhí)行“a=(x? 10:4*2);”語句后a的值為 10 。37假定a=5,則條件表達式“a= =0? 10:2
5、0”的值為 20 。38執(zhí)行“typedef int data type;”語句后,在使用int定義整型變量的地方都可以使用 datatype 定義整型變量。39設x和y均為bool量,x & & y為真的條件是 x=true y=true 。40設x和y均為bool量,則x | | y為假的條件是 x、y都為false 。二、寫出下列程序運行后的輸出結(jié)果1#include void sb (char ch) switch (ch) case a :case a: cout ”well”!” ; break; case b: case b: cout ”good!” ;break; case
6、c: case c: cout ”pass!” ;break; default : cout “bad!” ; break;void main () char al=b,a2=c,a3=f; sb(al);sb(a2);sb(a3);sb(a); cout endl;good!pass!bad!well!2、#clude #includedouble sd(int a,int b,char op) double x; switch (op) case x:x=double(a) + b; break; case -: x=double (a) b; break; case * x=double
7、 (a) * b;break; case /:if (b) x=double (a)/b; else exit(1); break; default:exit(1); return x; void main ()int x=20 ,y=12;cout sd(x,y,-) ;cout sd(x,y,*) ;cout sd(x+y,y-2,/)endl;8 240 3.23、#include void main () int s=0; for (int i=1;i6;i+) s+=i*i; cout ”s=”sendl;s=554、# include void main () int s=0; f
8、or (int i=1;i+) if (s50) break; if (i%3= =0) s+=i; cout ”i,s=”i”,”sendl;i,s=19,635、# include void main ()int s1=0,s2=0;for (int i=0;i10;i+) if (i%2) s1+=i; else s2 +=i;cout s1 s2endl;25 206、# include void main ()int n=10,y=1;while (n-)y+;+y;cout ”y*y=”y*yendl;y*y=441三、寫出下列每個函數(shù)的功能1include int sa(int
9、a,int b) if(ab) return 1; else if(a= =b) return 0; else return 1;比較兩個整數(shù)a和b,如果a大于b則返回1;如果a等于b則返回0;如果a小于b則返回-1。2int sc(int a,int b,int c) if(a=b & a=c) return a;if(b=a & b=c) return b;if(c=a & c=b) return c;返回a、b、c三個數(shù)中的最大數(shù)。3int se(int n) / /n為大于等于1的整數(shù)int x;cinx;if(n= =1) return x;int m=x;while(n) cinx
10、; m+=x;return m;求輸入的n個數(shù)之和。4double sf (double x,int n) / /n為大于等于0的整數(shù) double p=1,s=1; for(int i=1;i=n;i+ +) p* =x;s+ =p/(i+1); return s; 計算1+x/2+x2/3+x3/4+xn/(n+1)5includebool sg(int x) / /x為大于等于2的整數(shù) int a=int(sqrt(x);/ /取x的平方根 int i=2; while(i=a) if(x%i= =0) break; i+ +; if(ix; while(x!= 100) n+ +;y+
11、=x; cinx; if(n= =0) return y;else return y/n; 求鍵盤輸入的數(shù)的平均值,輸入-100結(jié)束(不計在平均值內(nèi)),若沒有數(shù)輸入則返回0。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 wante
12、d to meet ivory coast international toure to discuss 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. yo
13、u can always find money from somebody to pay them.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 hav
14、e today in our game. but it is only with harsh 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 wi
15、ll attend citys premier league match at chelsea 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 agai
16、nst cskafor the racist behaviour of their fans 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
17、 added: we found no racist insults from fans of 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
18、 precipitation or humidity and limited cloud cover. 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
19、the cruising altitude of commercial airliners (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 ste
20、p out onto something resembling an olympic diving 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
21、 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. like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to earth. but this will not be enough to stop
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030年中國鋁擠壓行業(yè)市場運營狀況及發(fā)展趨勢分析報告
- 2025-2030年中國金屬波紋補償器市場發(fā)展狀況及前景趨勢分析報告
- 2025天津市安全員《B證》考試題庫及答案
- 2025-2030年中國聚對苯二甲酸丁行業(yè)投資戰(zhàn)略決策研究報告
- 2025-2030年中國紡織機械制造產(chǎn)業(yè)十三五規(guī)劃及投資戰(zhàn)略研究報告
- 2025-2030年中國石斑魚市場運行狀況與十三五規(guī)劃研究報告
- 2025-2030年中國電熱水器行業(yè)競爭格局及投資戰(zhàn)略研究報告
- 2025年江西省建筑安全員A證考試題庫附答案
- 欽州幼兒師范高等??茖W?!缎履茉雌嚱Y(jié)構(gòu)與原理》2023-2024學年第二學期期末試卷
- 2025浙江省安全員考試題庫
- 借哪吒精神燃開學斗志 開學主題班會課件
- GB/T 45107-2024表土剝離及其再利用技術要求
- 一年級家長會課件2024-2025學年
- 2024年海南省海口市小升初數(shù)學試卷(含答案)
- 廣東省五年一貫制語文試卷
- 新版北師大版小學3三年級數(shù)學下冊全冊教案完整(新教材)
- 過橋資金(新)
- 顱內(nèi)壓監(jiān)測的方法與護理ppt課件
- 房地產(chǎn)項目盈虧平衡分析
- 中興網(wǎng)管日常操作
- 《綜采工作面綜合防塵技術規(guī)范》
評論
0/150
提交評論