大写字母:65以上
小写字母:97以上
然后就是注意第一个字母可以大写不影响规范
Go版本
import "fmt"
func detectCapitalUse(word string) bool {
temp:=0;
// res:="";
// A 65
tmp_big:=0
tmp_small:=0
for i:=0;i<len(word);i++{
temp=int(word[i])
fmt.Println(temp)
if temp>=65 && temp<96{
if i==0{
tmp_big=0
}else{
tmp_big=1;
}
}
if temp>96 {
tmp_small=1;
}
}
if tmp_big==1 && tmp_small==1{
return false
}
return true
}
网友评论