




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
習(xí)題4
1.#include"iostream.h〃
voidmain()
(
doublea,b,c,max;
cout<<”請輸入三個(gè)數(shù):“<<endl;
cin>>a>>b?c;
if(a>b)max=a;
elsemax=b;
if(max<c)max=c;
cout<<〃最大數(shù)為:〃《max〈〈endl;
)
3.#include"iostream.h〃
voidmain()
inti,count=0;
for(i=l;i<=1000;i++)
if(i%9==0&&i%ll==0)
cout?i<<,\t);
count++;
if(count%5==0)cout?endl;
)
)
4.If-else語句答案:
#includeiostream.h〃
voidmain()
{
intscore;
cout<〈”請輸入百分制成績:”;
cin?score;
if(score>100||score<0)
cout<<〃輸入的成績有錯(cuò)!〃<Xendl;
else
(
cout〈〈〃\n五分制成績?yōu)椋骸ǎ?/p>
if(score>=90)cout?,A*<<endl;
elseif(score>=80)cout?,B*?endl;
elseif(score>=70)cout<<'C'<<endl;
elseif(score>=60)cout?,D*?endl;
elsecout<<,E*<<endl;
}
)
Switch語句答案:
ttinclude“iostream.h〃
voidmain()
(
intscore;
coutG〃請輸入百分制成績:〃;
cin>>score;
if(score>100||score<0)
cout<〈”輸入的成績有錯(cuò)!"<<endl;
else
(
cout?〃\n五分制成績?yōu)椋骸ǎ?/p>
switch(score/10){
case10:
case9:cout?,A*<<endl;break;
case8:cout?,B'?endl;break;
case7:cout?,C'<<endl;break;
case6:cout?,D'<<endl;break;
default:cout?,E'<<endl;
)
)
)
5.If-else語句答案:
ttinclude"iostream.h〃
voidmain()
(
intbasel,base2,base3,base4,base5,base6,base7,base8;
floatmoney,tax;
basel=0.05*500;
base2=basel+0.1*1500;
base3=base2+0.15*3000;
base4=base3+0.2*15000;
base5=base4+0.25*20000;
base6=base5+0.3*20000;
base7=base6+0.35*20000;
base8=base7+0.4*20000;
coutC〈〃請輸入收入金額:〃;
cin>>money;
if(money<0)
cout<<〃輸入的金額不能是負(fù)數(shù)!”〈〈endl;
else
(
money二money-800;
if(money<=0)tax=0;
elseif(money<=500)tax=money*O.05;
elseif(money<=2000)tax=basel+(money-500)*0.1;
elseif(money<=5000)tax=base2+(money-2000)*0.15;
elseif(money<=20000)tax=base3+(money-5000)*0.2;
elseif(money<=40000)tax=base4+(money-20000)*0.25;
elseif(money<=60000)tax=base5+(money-40000)*0.3;
elseif(money<=80000)tax=base6+(money-60000)*0.35;
elseif(money<=100000)tax=base7+(money-80000)*0.4;
elsetax=base8+(money-100000)*0.45;
cout?〃\n應(yīng)繳稅款為:〃<<tax<〈endl;
}
}
6.#include"iostream.h〃
voidmain()
{
inti,a,b,c,d;
for(i=1000;i<10000;i++)
(
a=i/1000;〃千位
b=i%1000/100;〃百位
c=i%100/10;〃十位
d=i%10;〃個(gè)位
if(a*a*a*a+b*b*b*b+c*c*c*c+d*d*d*d=二i)
cout?i?,\t*;
)
cout<<endl;
)
7.#includeiostream.h,z
ttinclude"math,h"
voidmain()
(
inti,j,m;
for(i=2;i<1000;i++)
(
m=sqrt(i);
for(j=2;j<=m;j++)
if(i%j==O)break;
if(j>=m+l)
cout?i?,\t);
)
cout<<endl;
)
8.#include"iostream.h〃
voidmain()
(
intbeginCol=5,i,j,m;
for(i=7,j=4;j>0;j—,i-=2)
(
for(m=0;m<beginCo1+4-j;m++)
cout<<'';
for(m=0;m<i;m++)
cout?,*';
cout<<endl;
)
for(i=3,j=2;j<=4;j++,i+=2)
(
for(m=0;m<beginCol+4-j;m++)
cout?,’;
for(m=0;m<i;m++)
cout?,*';
cout<<endl;
)
cout?endl;
)
9.#include“iostream.h〃
voidmain()
(
inti,x,y,z;
for(x=l;x<=9;x++)
for(y=0;y<=9;y++)
for(z=0;z<=9;z++)
if(x!=y&&y!=z&&z!=x&&(x*100+y*10+z)/ll=0)
cout<<x*100+y*10+z?'\t';
cout<<endl;
}
10.#include“iostream.h〃
voidmain
溫馨提示
- 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 鄉(xiāng)村土地承包經(jīng)營獎補(bǔ)資金使用協(xié)議
- 二手房買賣過戶網(wǎng)簽協(xié)議
- 健康飲食品牌推廣合同書
- 本季度銷售業(yè)績匯報(bào)與展望
- 高體三教授治療眩暈病學(xué)術(shù)思想研究
- 體育健身產(chǎn)業(yè)智能健身設(shè)備研發(fā)及市場推廣計(jì)劃
- 在線教育合作協(xié)議
- 中國古詩詞啟蒙的故事情節(jié)解析
- 船舶調(diào)試知識培訓(xùn)課件
- 體育賽事活動組織執(zhí)行協(xié)議
- 《元德秀字紫芝》2019年山東濰坊中考文言文閱讀真題(含答案與翻譯)
- 建設(shè)“三型三化551”財(cái)務(wù)體系加快財(cái)務(wù)轉(zhuǎn)型創(chuàng)建一流財(cái)務(wù)指導(dǎo)意見
- 語言領(lǐng)域核心經(jīng)驗(yàn)《學(xué)前兒童語言學(xué)習(xí)與發(fā)展核心經(jīng)驗(yàn)》
- 湖北省華中師大一附中2020-2021高一物理期中檢測試卷【含答案】
- 2021年合肥職業(yè)技術(shù)學(xué)院職業(yè)適應(yīng)性測試試題及答案解析
- 2022年三年級美術(shù)下冊教案課題美化教室一角
- 初中物理公式MicrosoftWord文檔
- 詐騙案件授課PPT課件
- 弗洛姆異化理論
- 碳納米管_ppt課件
- 【課件】第2課如何鑒賞美術(shù)作品課件-高中美術(shù)人教版(2019)美術(shù)鑒賞
評論
0/150
提交評論