[解题报告]The Decoder

题目大意

题目原文:http://uva.onlinejudge.org/external/4/458.pdf

背景

编一个程序,将一串字符进行解码,解码之后打印出这串字符

 

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.

算法:

问题的关键就是在找出解码之后与解码之前的关系,也就是我代码中的t='1'-'t';

这就是问题的所在,之后其他的代码解码也就是按照这样的关系进行下去了。

代码:这里附上我的代码,你可以去这里提交你的代码验证你的代码是否正确,

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     int t,i;
 6     char s[1000];
 7 
 8     t='1'-'*';
 9 
10     while(gets(s)!=NULL)
11     {
12         int num=strlen(s);
13         for(i=0;i<num;i++)
14             s[i]-=t;
15         puts(s);
16     }
17     return 0;
18 }

 

转载于:https://www.cnblogs.com/qisong178878915/archive/2013/02/04/2892199.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值