Description
把一个字符串里所有的大写字母换成小写字母,小写字母换成大写字母。其他字符保持不变。
Input
输入为一行字符串,其中不含空格。长度不超过80个字符。
Output
输出转换好的字符串。
Sample
Input
ABCD123efgh
Output
abcd123EFGH
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
String str;
str = reader.nextLine();
for(int i = 0; i < str.length(); i++) {
char s = str.charAt(i);
if(s <= 'z' && s >= 'a') {
s -= 32;
System.out.print(s);
} else if(s <= 'Z' && s >= 'A') {
s += 32;
System.out.print(s);
} else System.out.print(s);
}
reader.close();
}
}