如果if中的 执行语句只有一条时,可以写成下面这样 program main integer a a=101 if (a>100) write(*,*) "slow down" end 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 这样省略了 then 和 end if F90 使用逻辑符号来表示 如 == ,/=, < , > 等来表示。 F77 要使用缩写来做 逻辑判断。 .EQ. ...
也就是说,虽然if-else if 这个从句中含有两个if判断,但在最后条件判断结束后,只需要写 一个end if就OK了,不用写多个,如: if ( salary < 1000 ) then ! do something else if ( salary > 5000) then ! do something end if 3、如果if语句后只有一句代码,那么要注意then和end if都应该省略不写,如 ...
一个IF模块【或者语句】 一个IF-ELSE模块 多个IF嵌套 多重判断 IF-ELSE IF模块 基本用法 一个IF模块 IF(逻辑判断式)THEN 【条件成立时要判断的语句】 【否则】 如果IF模块中只有一行程序代码,可以把IF跟这行代码写在同一行,并省略THEN和END IF IF(逻辑判断 )... 可以搭配ELSE,用来赋值,当判断式不成立时,...
ELSE IF (MOD(NUMBER, 3) == 0) THEN PRINT*, "NUMBER DIVIDED BY 3 IS ZERO!" ELSE PRINT*, "OTHER NUMBERS." END IF 上述结构中,ELSE IF以及ELSE语句都可以省略。 如果判断之后只有一条语句执行,则IF后面的THEN关键字可以省略。例如: REAL*8 :: X, ABS_X READ(*,*) X ABS_X = X IF (...
2、IF (1) 基本 if(逻辑判断式)then……endif 如果then后面只有一句,可写为 if(逻辑判断式) ……!then和end if可省略 (2) 多重判断 if(条件1)then……elseif(条件2)then……elseif(条件3)then……else……endif (3) 嵌套: if(逻辑判断式)thenif(逻辑判断式)thenif(逻辑判断式)thenelseif(逻辑判断...
.EQV.:当两边逻辑运算值相同时为真,.NEQV.:当两边逻辑运算值不同时为真2、IF(1)基本:if(逻辑判断式)then……endif如果then后面只有一句,可写为if(逻辑判断式)……!then和endif可省略(2)多重判断:if(条件1)then……elseif(条件2)then……elseif(条件3)then……else……endif(3)嵌套:if(逻辑...
基本程序块: if(逻辑判断式)then ... end if 或是 if(逻辑判断式)then ... else ... end if 多重嵌套 if(...)then if(...)then else if(...)then else end if end if 注:如果所需要执行的程序模块只有一行程序代码,可以把if跟这行代码写在同一行,可省略then和end if. if (逻辑判断)......
If radius and height could not be read from input, then cycle through the loop.if(ierr/=0)thenwrite(*,*)'Error, invalid input.'cycleinteractive_loop!cycle 相当于C里的continueend if! Compute area. The ** means "raise to a power."area=2*pi*(radius**2+radius*height)! 指数运算比C方...
2、IF (1) 基本 : if(逻辑判断式) then …… end if 如果then后面只有一句,可写为 if(逻辑判断式) …… !then和end if可省略 (2) 多重判断: if(条件1) then …… else if(条件2)then …… else if (条件3)then …… else ……
if… then语句可以后跟一个可选的else语句, 它执行时,逻辑表达式为假。 语法 if… then… else的基本语法: if(logical expression)thenstatement(s)elseother_statement(s)endif 但是,如果给定if块一个名字,然后命名if-else语句的语法是,这样的: [name:]if(logical expression)then!various statements...else!oth...