我们如何找出输入字符的下一个字符.例如,如果我输入了字符b",那么如何得到答案c"?
How we can find out the next character of the entered one. For example, if I entered the character "b" then how do I get the answer "c"?
试试这个:
char letter = 'c';
if (letter == 'z')
nextChar = 'a';
else if (letter == 'Z')
nextChar = 'A';
else
nextChar = (char)(((int)letter) + 1);
这样,当字符是字母表的最后一个时,您就不会遇到麻烦.
This way you have no trouble when the char is the last of the alphabet.
这篇关于如何按字母顺序找出下一个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!