資源描述:
《fortran95程序設(shè)計(jì)課后習(xí)題答案(word版方便)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、第四章1.programmainimplicitnonewrite)*,*)"Haveagoodtime."write(*,*)"That'snotbad.'1write(*,*)'"Mary"isn"tmyname.'endprogram2.programmainreal,parameter::Pl=3implicitnone.14159realradiuswrite(*,*)"請(qǐng)輸入半徑長(zhǎng)"read)*,*)radiuswrite(*/"(,面積='f8.3)")radius*radius*PIendp
2、rogram3.programmainimplicitnonerealgradeswrite(*,*)"請(qǐng)輸入成績(jī)”read(*,*)gradeswrite(*,"('調(diào)整后成績(jī)?yōu)?8.3)")SQRT(grades)*10.0endprogram4.integerazbrealra,rba=2b=3ra=2.0rb=3.0write(*/)b/a!輸出1,因?yàn)槭褂谜麛?shù)計(jì)算,小數(shù)部分會(huì)無(wú)條件舍去write(*,*)rb/ra!輸出1.55.programmainimplicitnonetypedistane
3、erealmeter,inch,cmendtypetype(distance)::dwrite(*,*)”請(qǐng)輸入長(zhǎng)度:"read(*,*)d%meterd%cm=d%meter*100d%inch=d%cm/2.54write(*,"(f8.3'米='f8.3'厘米Mf83英寸')”)d%meter,d%cm,d%inchendprogram第五章1.programmainimplicitnoneintegermoneyrealtaxwrite(*,*)"請(qǐng)輸入月U攵入"read(*,*)money訐(mo
4、neyvlOOO)thentax=0.03else訐(moneyv5000)thentax=0.1elsetax=0.15endifwrite(*/"(,稅金為'18)")nint(money*tax)endprogram2.programmainimplicitnoneintegerdaycharacter(len二20)::tvwrite(*,*)"請(qǐng)輸入星期幾”read(*,*)dayselectcase(day)case(l,4)tv="新聞"case(2,5)tv=“電視劇“case(3,6)tv
5、=”卡通“case(7)tv=11電影”casedefaultwrite)*,*)"錯(cuò)誤的輸入”stopendselectwrite(*,*)tvendprogram3.programmainimplicitnoneintegerage,moneyrealtaxwrite(*,*)”請(qǐng)輸入年齡"read(*,*)agewrite(*,*)"請(qǐng)輸入月收入”read)*/)money訐(age<50)thenif(money<1000)thentax=0.03else訐(money<5000)thentax=0
6、.10elsetax=0.15endifelse訐(money<1000)thentax=0.5else訐(moneyv5000)thentax=0.7elsetax=0.10end訐endifwrite(*z"('稅金為'18)")nint(money*tax)endprogram4.programmainimplicitnoneintegeryear,dayslogicalmod_4,mod_100/mod_400write(*,*)”請(qǐng)輸入年份"read(*,*)yearmod_4=(MOD(year
7、,4)==0)mod_100=(MOD(year,100)==0)mod_400=(MOD(year,400)==0)訐((mod_4.NEQV.mod_100).or.mod_400)thendays=366elsedays=365end訐write(*,"('這一年有'13天)”)daysstopendprogram第六章1.programmainimplicitnoneintegeridoi=l,5write(*,*)"Fortran"enddostopendprogram2.programmaini
8、mplicitnoneintegeri,sumsum=0doi=l,99z2sum=sum+ienddowrite)*,*)sumstopendprogram3.programmainimplicitnoneinteger,parameter::answer=45integer,parameter::max=5integerweight,idoi=l,maxwrite(*,*)”請(qǐng)輸入體重”read(*,*)we