if-else

作者: BANGBANGNT | 来源:发表于2017-12-07 17:10 被阅读0次
    package main
    
    import "fmt"
    
    func main() {
    
        if 7%2 == 0 {
            fmt.Println("7 is even")
        } else {
            fmt.Println("7 is odd")
        }
    
        if 8%2 == 0 {
            fmt.Println("8 is devisible by 4")
        }
    
        if num := 9; num < 0 {
            fmt.Println(num, " is negative")
        } else if num < 10 {
            fmt.Println(num, "has 1 digit")
        } else {
            fmt.Println(num, "has multiple digits")
        }
    }
    
    

    相关文章

      网友评论

          本文标题:if-else

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