美文网首页Fortran
😄Fortran--逻辑操作符

😄Fortran--逻辑操作符

作者: YI_YI_ | 来源:发表于2019-03-25 16:06 被阅读0次
    与,或,非
    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

    相关文章

      网友评论

        本文标题:😄Fortran--逻辑操作符

        本文链接:https://www.haomeiwen.com/subject/suhbvqtx.html