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 }

 

转载于:https://www.cnblogs.com/DAXS/p/3870093.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值