Go题库10_字符个数统计
作者:互联网
package main import ( "bufio" "fmt" "os" ) func main() { scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { str := scanner.Text() if len(str) == 0 { break } arr := [501]bool{} for _, num := range string(str) { if num >= 0 && num <= 127 { arr[num] = true } } var times int for _, item := range arr { if item { times++ } } fmt.Println(times) } }
标签:10,scanner,num,str,Go,题库,main,os,bufio 来源: https://www.cnblogs.com/luwei0915/p/15523030.html