在DO和END DO之间的语句块不确定地重复执行,知道逻辑表达式变为真,执行了EXIT语句。EXIT语句执行后,...
print *, 'sum',y,' term=',i end DOWHILE语句 例子 read *, n j=int(sqrt(n*1.)); i=2 do while ((mod(n,i)/=0) .and. (i<=j)) i=i+1 end do if(i<j) then print *, '不是素数,可被',i,'整除' else print *, '是素数' end if end 例子 !碾转相除法:如27和6,先用...
(K=1,J=1)(K=1,J=2)(K=2,J=1)(K=2,J=2)的顺序 现在的语法不建议用 continue 结束.你的语句这样写更符合现代语法:Do k = 1 ,2 Do j = 1 ,2 End Do End Do
没有区别的,等价的。Fortran77普遍使用“do和continue组合”,continue前面是有一个标号的,是一种老的处理方式
exit的功能是可以直接跳出一个正在进行的循环,不论是do 循环还是do while 循环,相当于python和C中的break。 1program sime23implicitnone4integer :: tn56tn=27print_tn :do8print *, tn9tn = tn+210if(tn>=200) exit print_tn11enddoprint_tn12pause1314end ...
The END DO statement is the delimiting statement of a Block DO statement. If the statement label is not specified in a DO statement, the corresponding terminating statement must be an END DO statement. You can branch to an END DO statement only from within the range of the DO loop that ...
Print matrix awrite(*,'(/,a)')"a ="write(*,fmt=outFormat)((a(i,j),j=1,N),i=1,N)!Print matrix bwrite(*,'(/,a)')"b ="write(*,fmt=outFormat)((b(i,j),j=1,N),i=1,N)end program do_concurrent_checkerboard_selection...
赋值符号两边只能是数组。然而在实际使用中,FORALL结构的运算速度并不比do循环快,有时甚至比do循环还...
do while(rep) ... ! 档rep为真时,一直执行循环体。 ... end do循环控制循环控制语句主要有CYCLE和EXIT。cycle命令可以略过循环程序模块中,cycle命令后面的所有程序代码,直接跳到循环的开头来进行下一次循环。exit的功能是直接跳出当前循环,不论是do循环还是do-while循环。循环还可以...
end do 1. 2. 3. 4. 5. 6. 上面用来做计数器的counter变量,脱离了循环语句之后就不能再用任何其他命令去改变器数值,不然编译就会出错。 随遍写个Do循环试一试: program main integer number number=1 do counter = 1, 100, 1 number=number+counter ...