当前位置: 代码迷 >> 综合 >> HDOJ 1048 The Hardest Problem Ever
  详细解决方案

HDOJ 1048 The Hardest Problem Ever

热度:115   发布时间:2023-10-21 19:51:55.0

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 = 0; i < str.length(); i++) {char c = str.charAt(i);if (c <= 'Z' && c >= 'A') {System.out.print((char)((c-65-5+26)%26+65));continue;}System.out.print(c);}System.out.println();}}
}
  相关解决方案