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]);//输出明文-------1 27 } 28 /*********************************/ 29 30 31 32 System.out.println();//没有此句会出现Presentation Error--------2 33 in.nextLine();//接受"END"语句--------3 34 35 36 //123、132、312的顺序均可 37 38 39 } 40 if(s.equals("ENDOFINPUT")) break; 41 42 43 } 44 } 45 46 }

 

JAVA HDU 1048 The Hardest Problem Ever,布布扣,bubuko.com

JAVA HDU 1048 The Hardest Problem Ever

上一篇:python 的经常使用时间操作,取得当前时间等


下一篇:javascript实现拖曳与拖放图片