问题遇到的现象和发生背景
切片越界?
用代码块功能插入代码,请勿粘贴截图
package main
import (
"fmt"
"math"
"os"
t "tools"
)
func main() {
args := os.Args
var W float64
var H float64
fmt.Sscanf(args[1], "%f", &W)
fmt.Sscanf(args[2], "%f", &H)
BMI := W / math.Pow(H, 2)
if BMI < 18.5 {
t.Printfln("偏瘦")
} else if 18.5 <= BMI && BMI <= 24 {
t.Printfln("正常")
} else if 24 <= BMI && BMI < 28 {
t.Printfln("偏胖")
} else if 28 <= BMI && BMI < 30 {
t.Printfln("肥胖")
} else {
t.Printfln("重度肥胖")
}
}
运行结果及报错内容
我想要达到的结果
正常run