Cprimerplus編程練習(xí)答案_第1頁(yè)
Cprimerplus編程練習(xí)答案_第2頁(yè)
Cprimerplus編程練習(xí)答案_第3頁(yè)
已閱讀5頁(yè),還剩7頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、C+ +p r i me rp l u s編程練習(xí)答案注:本人暑假正在看這本書(shū),順便就把題目做了,均經(jīng)過(guò)了編譯器通過(guò),無(wú)注釋。第二章1: #include<iostream>#define max 10using namespace std;void main()char namemax,dizhimax;cout<<" 請(qǐng)輸入姓名 : "cin>>name;cout<<" 請(qǐng)輸入地址 : "cin>>dizhi;cout<<" 姓名 ->"<<

2、name<<"t地址 ->"<<dizhi<<endl;2: #include<iostream>using namespace std;void main()long juli;cout<<" 請(qǐng)輸入距離 long(1 long為 220 碼 ):"cin>>juli;cout<<" 按照您輸入的距離是:"<<juli*220<<"碼"<<endl;3: #include<iostr

3、eam>using namespace std;void blind()cout<<"Three blind micen"void run()cout<<"See how they runn"void main()for(int i=0;i<2;i+)blind();for(int j=0;j<2;j+)run();4: #include<iostream>using namespace std;void month(int age)cout<<" 該年齡一共包含 "&

4、lt;<age*12<<" 個(gè)月! n"void main()int age;cout<<" 請(qǐng)輸入年齡 :"cin>>age;month(age);5: #include<iostream>using namespace std;double fahrenheit(double celsius)return *celsius+;void main()double celsius;cout<<"please enter a celsius value:"cin>&

5、gt;celsius;cout<<celsius<<" degrees celsius is "<<fahrenheit(celsius)<<" degrees fahrenheit.n"6: #include<iostream>using namespace std;double astronomical(double light)return 63240*light;void main()double light;cout<<"Enter the number of l

6、ight years:"cin>>light;cout<<light<<" light years = "<<astronomical(light)<<"astronomical units.n"7: #include<iostream>using namespace std;void display(int hours,int minutes)cout<<"Time: "<<hours<<":"&

7、lt;<minutes<<endl;void main()int hour,minute;cout<<"please input the time of hour:"cin>>hour;cout<<"please input the time of minute:"cin>>minute;display(hour,minute);第三章1: #include<iostream>using namespace std;const float danwei=;void iswap(

8、int cun)cout<<" 您的身高為 : "<<cun*danwei<<"英尺 !"<<endl;void main()int cun;cout<<" 請(qǐng)輸入英寸單位的身高( 整數(shù) ):_bbbbbb"cin>>cun;iswap(cun);2: #include<iostream>using namespace std;const double yingchi=12;const double bang=;const double memter=

9、;void caculate(double chi,double cun,double weight)double BMI;double yingcun,mi,qianke;yingcun=cun+chi*yingchi;mi=yingcun*memter;qianke=weight/bang;BMI=qianke/(mi*mi);cout<<" 您的 BMI 值為 : "<<BMI<<endl;void main()double chi,cun,weight;cout<<" 請(qǐng)輸入身高 ( 以幾英尺幾英寸方式輸入)

10、: "cin>>chi>>cun;cout<<" 請(qǐng)輸入體重 ( 以磅為單位 ): "cin>>weight;caculate(chi,cun,weight);3: #include<iostream>using namespace std;void main()double degrees,minutes,seconds,sum; cout<<"Enter a latitude in degrees,minutes,andseconds:"<<endl;cou

11、t<<"First,enter the degrees: "cin>>degrees;cout<<"Next,enter the minutes of arc: "cin>>minutes;cout<<"Finally,enter the seconds of arc: "cin>>seconds;sum=degrees+minutes/60+seconds/3600;cout<<degrees<<" degrees,"

12、<<minutes<<"minutes,"<<seconds<<" seconds= "<<sum<<" degrees."<<endl;4: #include<iostream>using namespace std;const long m=60;const long h=60;const long d=24;int sumday(long seconds)long hour,minute;minute=seconds/m;hour=m

13、inute/h;return hour/d;int sumhour(long seconds,int day)long minute;seconds=seconds-day*d*h*m;minute=seconds/m;return minute/h;int summinute(long seconds,int day,int hour)seconds=seconds-(day*d*h*m+hour*h*m); return seconds/m;int sumsecond(long seconds,int day,int hour,int minute)return seconds=secon

14、ds-(day*d*h*m+hour*h*m+minute*m);void main()long seconds;int day,hour,minute,second;cout<<"Enter the number of seconds: "cin>>seconds;day=sumday(seconds);hour=sumhour(seconds,day);minute=summinute(seconds,day,hour);second=sumsecond(seconds,day,hour,minute);cout<<seconds&l

15、t;<" seconds = "<<day<<" days,"<<hour<<"hours,"<<minute<<" minutes,"<<second<<" seconds."<<endl;5: #include<iostream>using namespace std;void main()double world,us;cout<<"Enter

16、 the world's population: "cin>>world;cout<<"Enter the population of the us: "cin>>us;double bilv;bilv=us/world;cout<<"The population of the us is "<<bilv<<"% of the worldpopulation."<<endl;6: #include<iostream>usi

17、ng namespace std;void main()float memter,jialun;cout<<" 以美國(guó)風(fēng)格還是歐洲風(fēng)格顯示耗油量m為美國(guó), o 為歐洲!"<<endl;cout<<" 請(qǐng)輸入 (m 或 o):"char c;cin>>c;if(c='m')cout<<" 請(qǐng)輸入驅(qū)車?yán)锍?( 英里 ):"cin>>memter;cout<<"請(qǐng)輸入使用汽油量 ( 加侖 ):"cin>>jia

18、lun;cout<<"汽車耗油量為 :"<<memter/jialun<<"mpg."<<endl;elsecout<<"請(qǐng)輸入驅(qū)車?yán)锍?( 公里 ):"cin>>memter;cout<<"請(qǐng)輸入使用汽油量 ( 升):"cin>>jialun;float ofg;ofg=(100*jialun)/memter;cout<<"汽車耗油量為 :"<<ofg<<"L/100Km."<<endl;7: include<ios

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論