天天看点

HDOJ 1048 The Hardest Problem Ever

HDACM1048

此题就是一个转换的题目,简单

关键:System.out.print((char)((c-65-5+26)%26+65))

import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String strStar = sc.nextLine();
            if ("ENDOFINPUT".equalsIgnoreCase(strStar)) {
                break;
            }
            String str = sc.nextLine();
            String strEnd = sc.nextLine();
            for (int i = ; i < str.length(); i++) {
                char c = str.charAt(i);
                if (c <= 'Z' && c >= 'A') {
                    System.out.print((char)((c--+)%+));
                    continue;
                }
                System.out.print(c);
            }
            System.out.println();
        }
    }
}