if条件语句的表现形式:
1 |
//第一种最基本 |
if语句判断学生成绩1
1 |
//判断学生成绩 |
if语句判断学生成绩改进2
1 |
//判断学生成绩 |
注意顺序,下面的代码是错误的:
1 |
if(score >=80 && score <90){ |
switch
switch形式一
使用switch语句判断成绩:
1 |
package main |
switch形式二
1 |
|
switch形式三
判断月份
1 |
package main |
switch形式四
1 |
|
总结
1 |
1、switch 语句执行的过程自上而下,直到找到case匹配项,匹配项中无需使用break,因为Go语言中的switch默认给每个case自带break,因此匹配成功后不会向下执行其他的case分支,而是跳出整个switch。 |
版权声明: 本博客所有文章除特别声明外,均采用 CC BY 4.0 CN协议 许可协议。转载请注明出处!