資源描述:
《Fortran95程序設(shè)計課后習(xí)題答案(word版方便).docx》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、第四章1.programmainimplicitnonewrite(*,*)"Haveagoodtime."write(*,*)"That'snotbad."write(*,*)'"Mary"isn''tmyname.'endprogram2.programmainreal,parameter::PI=3implicitnone.14159realradiuswrite(*,*)"請輸入半徑長"read(*,*)radiuswrite(*,"('面積='f8.3)")radius*radius*PIendprogram3.programmainimp
2、licitnonerealgradeswrite(*,*)"請輸入成績"read(*,*)gradeswrite(*,"('調(diào)整后成績?yōu)?f8.3)")SQRT(grades)*10.0endprogram4.integera,brealra,rba=2b=3ra=2.0rb=3.0write(*,*)b/a!輸出1,因為使用整數(shù)計算,小數(shù)部分會無條件舍去write(*,*)rb/ra!輸出1.55.programmainimplicitnonetypedistancerealmeter,inch,cmendtypetype(distance)::d
3、write(*,*)"請輸入長度:"read(*,*)d%meterd%cm=d%meter*100d%inch=d%cm/2.54write(*,"(f8.3'米='f8.3'厘米='f8.3'英寸')")d%meter,d%cm,d%inchendprogram第五章1.programmainimplicitnoneintegermoneyrealtaxwrite(*,*)"請輸入月收入"read(*,*)moneyif(money<1000)thentax=0.03elseif(money<5000)thentax=0.1elsetax=0.1
4、5endifwrite(*,"('稅金為'I8)")nint(money*tax)endprogram2.programmainimplicitnoneintegerdaycharacter(len=20)::tvwrite(*,*)"請輸入星期幾"read(*,*)dayselectcase(day)case(1,4)tv="新聞"case(2,5)tv="電視劇"case(3,6)tv="卡通"case(7)tv="電影"casedefaultwrite(*,*)"錯誤的輸入"stopendselectwrite(*,*)tvendprogram
5、3.programmainimplicitnoneintegerage,moneyrealtaxwrite(*,*)"請輸入年齡"read(*,*)agewrite(*,*)"請輸入月收入"read(*,*)moneyif(age<50)thenif(money<1000)thentax=0.03elseif(money<5000)thentax=0.10elsetax=0.15endifelseif(money<1000)thentax=0.5elseif(money<5000)thentax=0.7elsetax=0.10endifendifwr
6、ite(*,"('稅金為'I8)")nint(money*tax)endprogram4.programmainimplicitnoneintegeryear,dayslogicalmod_4,mod_100,mod_400write(*,*)"請輸入年份"read(*,*)yearmod_4=(MOD(year,4)==0)mod_100=(MOD(year,100)==0)mod_400=(MOD(year,400)==0)if((mod_4.NEQV.mod_100).or.mod_400)thendays=366elsedays=365end
7、ifwrite(*,"('這一年有'I3'天')")daysstopendprogram第六章1.programmainimplicitnoneintegeridoi=1,5write(*,*)"Fortran"enddostopendprogram2.programmainimplicitnoneintegeri,sumsum=0doi=1,99,2sum=sum+ienddowrite(*,*)sumstopendprogram3.programmainimplicitnoneinteger,parameter::answer=45integer
8、,parameter::max=5integerweight,idoi=1,maxwrite(*,*)"請輸