> 数学 >
Fortran中这句if语句如何理解?
if(a) 120,100,100请解释一些这句话
人气:200 ℃ 时间:2020-06-14 13:03:07
解答

这是Fortran中Arithmetic IF Statement即算术if语句,它的含义就是:当if中的值,分别是<,=,> 0时,按相应顺序goto到后面的语句.具体到你的例子,就是:

当a < 0时, goto 120
当 a >=0时,goto 100

比如:

    read(*,*) a
    if (a) 120, 100, 100
120 print *, "< 0"    
    print *, "---"
    goto 200
100 print *, ">= 0"
200 continue

运行结果:

-1
 < 0
 ---

1
 >= 0
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版