Fortran

😄Fortran--逻辑操作符

2019-03-25  本文已影响0人  YI_YI_
与,或,非
program logicalOP
    implicit none
    
    logical :: a,b
    a = .true.
    b = .false.
    
    if(a .and. b) then
        print * ,"Line 1 - Condition is true"
    else
        print *,"Line 1 - Condition is false"
    end if
    
    if(a .or. b) then
        print *,"Line 2 - Condition is true"
    else
        print *,"Line 2 - Condition is false"
    end if
    
    !change values
    a = .false.
    b = .true.
    
    if(.not.(a .and. b)) then
        print *,"line 3 - Condition is true"
    else
        print *,"line 3 - Condition is false"
    end if
    
    if(b .neqv. a) then
        print *,"ine 4 - condition is true"
    else 
        print *,"line 4 - condition is false"
    end if
    
    if(b .eqv. a)then
        print *,"line 5 - condition is true"
    else
        print *,"line 5 - condition is false"
    end if
    
    read*
end program logicalOP
    
结果
result_logical.png
上一篇 下一篇

猜你喜欢

热点阅读