IBM Minus One

http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=2&problemid=21

这道题交了几次终于过了。。明明结果是对的。。。。

 1 //author:pz
 2 
 3 import java.io.IOException;
 4 import java.util.Scanner;
 5 
 6 public class Main {
 7     public static void main(String[] args) throws IOException {
 8         Scanner in = new Scanner(System.in);
 9         int n = in.nextInt();
10         for (int i = 1; i <= n; i++) {
11             String s = in.next();
12             System.out.println("String #" + i);
13             System.out.println(change(s));
14             System.out.println();
15         }
16     }
17 
18     private static char[] change(String s) {
19         char[] a = new char[s.length()];
20         for (int i = 0; i < s.length(); i++) {
21             a[i] = (char) (s.charAt(i) + 1);
22             if (a[i] == 'Z' + 1)
23                 a[i] = 'A';
24             if (a[i] == 'z' + 1)
25                 a[i] = 'a';
26         }
27         return a;
28     }
29 }
原文地址:https://www.cnblogs.com/pengzheng/p/3052738.html