4.2 Swift中if语句的多分支执行

前端之家收集整理的这篇文章主要介绍了4.2 Swift中if语句的多分支执行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

/**

if 语句的多分支执行

*/

@H_404_14@ let score:Double = 98.5

@H_404_14@ var res:String = ""

@H_404_14@ if score >= 90 {

@H_404_14@ res = "优秀"

@H_404_14@ } else if score >= 80 {

@H_404_14@ res = "良好"

@H_404_14@ } else if score >= 60 {

@H_404_14@ res = "及格"

@H_404_14@ } else if score >= 0 {

@H_404_14@ res = "不及格"

@H_404_14@ }

@H_404_14@ if score >= 90 {

@H_404_14@ res = "优秀"

@H_404_14@ } else {

@H_404_14@ if score >= 80 {

@H_404_14@ res = "良好"

@H_404_14@ } else {

@H_404_14@ if score >= 60 {

@H_404_14@ res = "及格"

@H_404_14@ }

@H_404_14@ else {

// if <#condition#> {

// <#code#>

// }

@H_404_14@ }

@H_404_14@ }

@H_404_14@ }

@H_404_14@ print(res)

猜你在找的Swift相关文章