码迷,mamicode.com
首页 > 其他好文 > 详细

uva 458 - The Decoder

时间:2014-07-22 00:38:34      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   strong   

 The Decoder 

Write a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that the characters contain. The code key for this simple coding is a one for one character substitution based upon a single arithmetic manipulation of the printable portion of the ASCII character set.

 

Input and Output

For example: with the input file that contains:

 

1JKJ‘pz‘{ol‘{yhklthyr‘vm‘{ol‘Jvu{yvs‘Kh{h‘Jvywvyh{pvu5
1PIT‘pz‘h‘{yhklthyr‘vm‘{ol‘Pu{lyuh{pvuhs‘I|zpulzz‘Thjopul‘Jvywvyh{pvu5
1KLJ‘pz‘{ol‘{yhklthyr‘vm‘{ol‘Kpnp{hs‘Lx|pwtlu{‘Jvywvyh{pvu5

your program should print the message:

*CDC is the trademark of the Control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*DEC is the trademark of the Digital Equipment Corporation.

Your program should accept all sets of characters that use the same encoding scheme and should print the actual message of each set of characters.

 

Sample Input

 

1JKJ‘pz‘{ol‘{yhklthyr‘vm‘{ol‘Jvu{yvs‘Kh{h‘Jvywvyh{pvu5
1PIT‘pz‘h‘{yhklthyr‘vm‘{ol‘Pu{lyuh{pvuhs‘I|zpulzz‘Thjopul‘Jvywvyh{pvu5
1KLJ‘pz‘{ol‘{yhklthyr‘vm‘{ol‘Kpnp{hs‘Lx|pwtlu{‘Jvywvyh{pvu5

 

Sample Output

 

*CDC is the trademark of the Control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*DEC is the trademark of the Digital Equipment Corporation.
bubuko.com,布布扣
 1 //样例已经告诉我们了,减7输出即可
 2 //由于需要读取空格,所以不宜采取cin>>,应改为getchar(); 
 3 //以下是代码: 
 4 #include<iostream>  
 5 #include<string.h>  
 6 #include<stdio.h>  
 7 #include<ctype.h>  
 8 #include<algorithm>  
 9 #include<stack>  
10 #include<queue>  
11 #include<set>  
12 #include<math.h>  
13 #include<vector>  
14 #include<map>  
15 #include<deque>  
16 #include<list>  
17 using namespace std;
18 int main()  
19 {  
20     char ch;  
21     while (~(ch = getchar()))  
22         putchar(ch == \n ? \n : ch - 7);  
23     return 0;  
24 }  
View Code

uva 458 - The Decoder,布布扣,bubuko.com

uva 458 - The Decoder

标签:style   blog   http   color   os   strong   

原文地址:http://www.cnblogs.com/qscqesze/p/3857753.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!