题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
package main import "fmt" func main() { var input string fmt.Scanf("%s", &input) tmp := 'a' - 'A' + 1 a:=[]int{2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9} //for循环的判断条件 for _, v := range input { if v >= '0' && v <= '9' { fmt.Print(string(v)) } else if v >= 'A' && v <= 'Z' { s := v + tmp if s > 'z' { s = 'a' } fmt.Print(string(s)) }else{ fmt.Print(a[v-'a']) } } }