andy6804tw
7/16/2016 - 10:19 AM

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=25960

import java.util.*;
 
public class Main {
 
 public static void main(String[] args) {
  Scanner scn = new Scanner(System.in);
  int n = scn.nextInt(), tot;
  for (int i = 0; i < n; i++) {
   String str = scn.next();
   char arr[] = str.toCharArray();
   for (int j = arr.length - 1; j >= 0; j--) {
    tot = arr[j];
    if (arr[j] >= 'A' && arr[j] <= 'Z') {
     tot = Character.toLowerCase(arr[j]);
    }
    if (arr[j] >= 'a' && arr[j] <= 'z') {
     tot = Character.toUpperCase(arr[j]);
    }
    System.out.printf("%c", tot);
   }
   System.out.println();
  }
 }
/* 
    題目:[Problem2] 迴文字串
    作者:1010
    時間:西元 2016 年 7 月 */
 
}