uva 458 - The Decoder

本博客介绍了一个程序,用于解码简单的字符替换编码,揭示隐藏在字符集中的消息。通过减去7的简单数学操作,可以解码特定编码格式的文本,展示其背后的实际含义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 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.
 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

转载于:https://www.cnblogs.com/qscqesze/p/3857753.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值