SECRET

 

7877708574708274728174838A78707C70717470848378758

47B7678817B8A857481888574818871747084837875847B8A

 

  1 package junit_test;
  2 
  3 import java.util.Scanner;
  4 
  5 //字母--暗文转换
  6 public class Change {
  7     
  8     public static String a2n(char a){
  9         String b = "FF";
 10         if(a == 'a' || a == 'A'){
 11             b = "70";
 12         }
 13         else if(a == 'b' || a == 'B'){
 14             b = "71";
 15         }
 16         else if(a == 'c' || a == 'C'){
 17             b = "72";
 18         }
 19         else if(a == 'd' || a == 'D'){
 20             b = "73";
 21         }
 22         else if(a == 'e' || a == 'E'){
 23             b = "74";
 24         }
 25         else if(a == 'f' || a == 'F'){
 26             b = "75";
 27         }
 28         else if(a == 'g' || a == 'G'){
 29             b = "76";
 30         }
 31         else if(a == 'h' || a == 'H'){
 32             b = "77";
 33         }
 34         else if(a == 'i' || a == 'I'){
 35             b = "78";
 36         }
 37         else if(a == 'j' || a == 'J'){
 38             b = "79";
 39         }
 40         else if(a == 'k' || a == 'K'){
 41             b = "7A";
 42         }
 43         else if(a == 'l' || a == 'L'){
 44             b = "7B";
 45         }
 46         else if(a == 'm' || a == 'M'){
 47             b = "7C";
 48         }
 49         else if(a == 'n' || a == 'N'){
 50             b = "7D";
 51         }
 52         else if(a == 'o' || a == 'O'){
 53             b = "7E";
 54         }
 55         else if(a == 'p' || a == 'P'){
 56             b = "7F";
 57         }
 58         else if(a == 'q' || a == 'Q'){
 59             b = "80";
 60         }
 61         else if(a == 'r' || a == 'R'){
 62             b = "81";
 63         }
 64         else if(a == 's' || a == 'S'){
 65             b = "82";
 66         }
 67         else if(a == 't' || a == 'T'){
 68             b = "83";
 69         }
 70         else if(a == 'u' || a == 'U'){
 71             b = "84";
 72         }
 73         else if(a == 'v' || a == 'V'){
 74             b = "85";
 75         }
 76         else if(a == 'w' || a == 'W'){
 77             b = "86";
 78         }
 79         else if(a == 'x' || a == 'X'){
 80             b = "87";
 81         }
 82         else if(a == 'y' || a == 'Y'){
 83             b = "88";
 84         }
 85         else if(a == 'z' || a == 'Z'){
 86             b = "89";
 87         }
 88         else if(a == ',' || a == '.'){
 89             b = "8A";
 90         }
 91         else if(a == ' '){
 92             b = "8B";
 93         }
 94         else b = "8C";
 95         return b;
 96     }
 97     
 98     public static char n2a(String a){
 99         char b = '0';
100         if(a.equals("70")){
101             b = 'a';
102         }
103         else if(a.equals("71")){
104             b = 'b';
105         }
106         else if(a.equals("72")){
107             b = 'c';
108         }
109         else if(a.equals("73")){
110             b = 'd';
111         }
112         else if(a.equals("74")){
113             b = 'e';
114         }
115         else if(a.equals("75")){
116             b = 'f';
117         }
118         else if(a.equals("76")){
119             b = 'g';
120         }
121         else if(a.equals("77")){
122             b = 'h';
123         }
124         else if(a.equals("78")){
125             b = 'i';
126         }
127         else if(a.equals("79")){
128             b = 'j';
129         }
130         else if(a.equals("7A")){
131             b = 'k';
132         }
133         else if(a.equals("7B")){
134             b = 'l';
135         }
136         else if(a.equals("7C")){
137             b = 'm';
138         }
139         else if(a.equals("7D")){
140             b = 'n';
141         }
142         else if(a.equals("7E")){
143             b = 'o';
144         }
145         else if(a.equals("7F")){
146             b = 'p';
147         }
148         else if(a.equals("80")){
149             b = 'q';
150         }
151         else if(a.equals("81")){
152             b = 'r';
153         }
154         else if(a.equals("82")){
155             b = 's';
156         }
157         else if(a.equals("83")){
158             b = 't';
159         }
160         else if(a.equals("84")){
161             b = 'u';
162         }
163         else if(a.equals("85")){
164             b = 'v';
165         }
166         else if(a.equals("86")){
167             b = 'w';
168         }
169         else if(a.equals("87")){
170             b = 'x';
171         }
172         else if(a.equals("88")){
173             b = 'y';
174         }
175         else if(a.equals("89")){
176             b = 'z';
177         }
178         else if(a.equals("8A")){
179             b = '.';
180         }
181         else if(a.equals("8B")){
182             b = ' ';
183         }
184         else b = '.';
185         return b;
186     }
187 
188     public static void write(){
189         System.out.println("  ========================================" );
190         System.out.println("============================================");
191         System.out.println("                  请输入原文,并以“#”结束:" );
192         Scanner sc = new Scanner(System.in);
193         String str = sc.nextLine(); 
194         char c[]=str.toCharArray(); 
195         int i = 0;
196         System.out.println("============================================");
197         System.out.println("  ========================================" );
198         System.out.println("                      叮咚~ 转换成功啦~" );
199         System.out.print("   " );
200         for(i = 0; c[i] != '#'&& i < 1000; i++){
201             String s = a2n(c[i]);
202             System.out.print( s );
203         }
204         System.out.println(" ");
205     }
206     
207     private static void read() {
208         System.out.println("  ========================================" );
209         System.out.println("============================================");
210         System.out.println("                  请输入暗文,并以“#”结束:" );
211         Scanner sc = new Scanner(System.in);
212         String str = sc.nextLine(); 
213         char c[]=str.toCharArray(); 
214         int i = 0;
215         System.out.println("============================================");
216         System.out.println("  ========================================" );
217         System.out.println("                      叮咚~ 转换成功啦~" );
218         System.out.print(" " );
219         for(i = 0; c[i] != '#'&& i < 2000; i = i + 2){
220             String s = str.substring(i, i+2);
221             char m = n2a(s);
222             System.out.print(m);
223         }
224         System.out.println(" ");
225         
226     }
227     
228     public static void main(String[] args) {
229         System.out.println("  ========================================" );
230         System.out.println("============================================");
231         System.out.println("           您好,欢迎进入字母--暗文转换系统。" );
232         System.out.println(" 请按照指示使用本系统。如有出错,请重启本系统。");
233         System.out.println("============================================");
234         System.out.println("  ========================================" );
235         int b = 0;
236         while(b != 3){
237             System.out.println("        ——————————————————————————" );
238             System.out.println("        |   请选择您所需要的操作: |");
239             System.out.println("        |   1.原文转换                     |" );
240             System.out.println("        |   2.暗文解读                     |" );
241             System.out.println("        |   3.退出系统                     |" );
242             System.out.println("        ——————————————————————————" );
243             Scanner sc = new Scanner(System.in);
244             b = sc.nextInt(); 
245             if(b == 1){
246                 write();
247             }
248             else if(b == 2){
249                 read();
250             }
251             System.out.println("  ========================================" );
252             System.out.println("============================================");
253             System.out.println("  ========================================" );
254         }
255         System.out.println("                              感谢使用!" );
256         System.out.println("  ========================================" );
257         System.out.println("============================================");
258         System.out.println("  ========================================" );
259     }
260 
261 
262 }
View Code

 

posted @ 2018-03-21 16:05  非职业天使  阅读(230)  评论(2编辑  收藏  举报