赞
踩
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 }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。