package main
import (
"flag"
"fmt"
)
func main() {
score := GetRenge(GetCmd())
fmt.Println(score)
}
func GetRenge(name,xz string,age,rmb float64,isafool bool) (score float64) {
score = 60
rmbAgeIndex := rmb / age / (400000.0/40.0)
score*=rmbAgeIndex
//UTF8中中文汉字占3个字节
if len(name)>=12{
score *= 1.1
}
switch xz{
case "天蝎","摩羯","水瓶":
score *= 1.1
case "处女":
score *= 0.9
}
if rmbAgeIndex>2 && isafool == true{
score*=1.1
}
if age>30 && rmb<400000 && !isafool{
score*=0.8
}
return
}
func GetCmd() (name,xz string,age,rmb float64,isafool bool) {
namePtr := flag.String("name", "无名氏", "姓名")
xzPtr := flag.String("xingzuo", "无", "星座")
agePtr := flag.Float64("age", 0, "年龄")
rmbPtr := flag.Float64("rmb", 0, "人民币")
foolPtr := flag.Bool("isafool", true, "傻不傻")
flag.Parse()
return *namePtr,*xzPtr,*agePtr,*rmbPtr,*foolPtr
}
[이동] 실제 전투에서 명령 줄 매개 변수의 성격 테스트
추천
출처blog.csdn.net/qq_36045898/article/details/113939887
추천
행