if条件语句的表现形式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
//第一种最基本 num := 26 if(num %2==0){ fmt.Printf("num是偶数\n") } //第二种 初始化: if str:="jonson"; num %2==0 { fmt.Printf(str) } //第三种 else语句: if(num %2==0){ fmt.Printf("num是偶数\n") }else{ fmt.Printf("num是奇数\n") } |
if语句判断学生成绩1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
//判断学生成绩 func scoreTest(){ var score =80 if(score >=90){ fmt.Printf("优秀") } if(score >=80 && score <90){ fmt.Printf("良好") } if(score >=70 && score <80){ fmt.Printf("中等") } if(score >=60 && score <70){ fmt.Printf("及格& |