package main

import "fmt"

func main(){
//注:在Go里面没有三元表达式”?:”,所以你只能使用条件判断语句。
//示例一
if 7%2==0{
fmt.Println("7 is even")
}else{
fmt.Println("7 is odd")
}

//示例二
if 8%4==0{
fmt.Println("8 is divisible 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")
}
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
猜你喜欢
  • 2021-09-23
  • 2022-12-23
  • 2022-01-30
  • 2021-12-30
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
相关资源
相似解决方案