资源描述:
《fortran学习过程中写的一些小程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Fortran学习过程中写的一些小程序1,多重循环的判断programex19implicitnoneintegerscorecharactergradewrite(*,*)"score:"read(*,*)scoreif(score>100)thengrade="?"elseif(score>=90)thengrade="A"elseif(score>=80)thengrade='B'elseif(score>=70)thengrade='C'elseif(score>=60)thengrade=
2、'D'elsegrade="?"endifwrite(*,*)gradestopendprogramex19implicitnoneintegerscorecharactergradewrite(*,*)"score:"read(*,*)scoreif(score>=90.and.score<=100)thengrade="A"elseif(score>=80.and.score<90)thengrade="B"elseif(score>=70.and.score<90)thengrade='C'e
3、lseif(score>=60.and.score<70)thengrade='D'elseif(score>=50.and.score<60)thengrade='E'elsegrade="F"endifwrite(*,*)gradestopendprogramex19implicitnonerealxrealyintegeranswrite(*,*)"请输入坐标:(x,y)"read(*,*)x,yif(x>0)thenif(y>0)thenans=1elseif(y<0)thenans=4el
4、seans=0endifelseif(x<0)thenif(y>0)thenans=2elseif(y<0)thenans=3elseans=0endifelseans=0endifif(ans/=0)thenwrite(*,"('第',I1,'象限')")anselsewrite(*,*)"在坐标轴上"endifstopendprogramex11implicitnonecharacter::str1,str2characterrelationwrite(*,*)"string1="read(*,
5、*)str1write(*,*)"string2="read(*,*)str2if(str1>str2)thenrelation=">"elseif(str1==str2)thenrelation="="elserelation="<"endifwrite(*,"('string1',A1,'string2')")relationstopendprogramex11implicitnoneintegerywrite(*,*)"y="read(*,*)yif(mod(y,4)==0.and.mod(y
6、,100)/=0.and.mod(y,400)==0)thenwrite(*,*)"闰年"elsewrite(*,*)"不是闰年"endifstopendprogrammainimplicitnoneinteger,parameter::dest=9integerfloordofloor=1,destif(floor==4)cyclewrite(*,*)floorenddostopendprogrammainimplicitnonereal,parameter::weight=45.0real,pa
7、rameter::error=0.001realgaussdowhile(abs(gauss-weight)>error)write(*,*)"weight="read(*,*)gaussenddowrite(*,*)"weight=",gaussstopendprogrammainimplicitnoneintegeri,jloop1:doi=1,3loop2:doj=1,3if(i==3)exitloop1if(j==2)cycleloop2write(*,"('(',i2,',',i2,')'
8、)")i,jenddoloop2enddoloop1stopendprogrammainimplicitnoneinteger::fn2=0integer::fn1=1integer::fn=0integercounterwrite(*,*)fn2write(*,*)fn1docounter=2,9fn=fn2+fn1write(*,"(I3)")fnfn2=fn1fn1=fnenddostopendprogrammainimplicitnoneintegeriint