首页 > 代码库 > JAVA HDU 1048 The Hardest Problem Ever
JAVA HDU 1048 The Hardest Problem Ever
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1048
1 package hdu; 2 3 import java.io.BufferedInputStream; 4 import java.util.Scanner; 5 6 public class hdu_1048 { 7 8 public static void main(String[] args) { 9 Scanner in = new Scanner(new BufferedInputStream(System.in));10 char cipher[] = {‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘, ‘F‘, ‘G‘, ‘H‘, ‘I‘, ‘J‘, ‘K‘, ‘L‘, ‘M‘,
‘N‘, ‘O‘, ‘P‘, ‘Q‘, ‘R‘, ‘S‘, ‘T‘, ‘U‘, ‘V‘, ‘W‘, ‘X‘, ‘Y‘, ‘Z‘ };11 char plain[] = {‘V‘, ‘W‘, ‘X‘, ‘Y‘, ‘Z‘, ‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘, ‘F‘, ‘G‘, ‘H‘,
‘I‘, ‘J‘, ‘K‘, ‘L‘, ‘M‘, ‘N‘, ‘O‘, ‘P‘, ‘Q‘, ‘R‘, ‘S‘, ‘T‘, ‘U‘ };12 13 while(true) {14 String s = in.nextLine();//接受"START"或"ENDOFINPUT"15 16 if(s.equals("START")) {17 String ss = in.nextLine();//接受密文18 19 /***********密文转换为明文**************/20 char c[] = ss.toCharArray();21 for (int i = 0; i < c.length; i++) {22 if(c[i] >=65 && c[i] <= 90) {23 c[i] = (char)plain[c[i] - 65];24 25 }26 System.out.print(c[i]);//输出明文-------127 }28 /*********************************/29 30 31 32 System.out.println();//没有此句会出现Presentation Error--------233 in.nextLine();//接受"END"语句--------334 35 36 //123、132、312的顺序均可37 38 39 }40 if(s.equals("ENDOFINPUT")) break;41 42 43 }44 }45 46 }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。