PAT 793. java大小写字母转化并倒序输出
原题链接
简单
作者:
bukki
,
2024-12-29 21:36:58
,
所有人可见
,
阅读 2
package com.yxc;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
StringBuffer sb = new StringBuffer();
String s1 = null;
for (int i = str.length() - 1; i >= 0; i--) {
char curChar = str.charAt(i);
if (curChar >= 'a' && curChar <= 'z')
s1 = String.valueOf(curChar).toUpperCase();
else if (curChar >= 'A' && curChar <= 'Z')
s1 = String.valueOf(curChar).toLowerCase();
else
s1 = String.valueOf(curChar);
sb.append(s1);
}
System.out.println(sb.toString());
}
}