题目:将输入的字母变成其下一个字母,并且元音字母大写
package main import "fmt" func LetterChanges(str string) string { bb := []rune(str) var str1 []rune for i:=0;i<len(bb);i++{ if (bb[i]>='a'&&bb[i]<='z'){ str1=append(str1,bb[i]+1) c:=str1[i] if (c == 'a'|| c == 'e' || c == 'u' || c== 'i' || c == 'o') { str1[i]=str1[i]-32 } } else { str1=append(str1,bb[i]) } } str=string(str1[0:]) // code goes here // Note: feel free to modify the return type of this function return str } func main() { aa:="gddd**3" fmt.Println(LetterChanges(aa)) }
知识点:
1、多个常数的比较 if (c == 'a'|| c == 'e' || c == 'u' || c== 'i' || c == 'o')
有疑问加站长微信联系(非本文作者)