博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[结题报告]458 - The Decoder Time limit: 3.000 seconds
阅读量:5981 次
发布时间:2019-06-20

本文共 1908 字,大约阅读时间需要 6 分钟。

 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{pvu51PIT'pz'h'{yhklthyr'vm'{ol'Pu{lyuh{pvuhs'I|zpulzz'Thjopul'Jvywvyh{pvu51KLJ'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{pvu51PIT'pz'h'{yhklthyr'vm'{ol'Pu{lyuh{pvuhs'I|zpulzz'Thjopul'Jvywvyh{pvu51KLJ'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. 代码参考: 本题主要是将字符串的每个部分都进行变化,通过观察可是原码和变化码之间ASCII码相差7.
#include"stdio.h"void fun(char *p)    //自定义函数;   {  int i=0;         //定义变量i,控制循环;      while(p[i])      //循环解码;     {p[i]-=7;                 i++;}    p[i]='\0';          //字符串结束;      } main() {    char s[30000];         //申请数组 ;        while(gets(s))                    { fun(s);               //调用函数;            printf("%s\n",s);        //输出;          }        }

 

转载于:https://www.cnblogs.com/sjy123/archive/2013/01/29/2881428.html

你可能感兴趣的文章
APP手工项目02-用例编写-测试报告-fiddler弱网测试
查看>>
Python之路(第九篇)Python文件操作
查看>>
Python学习笔记【第八篇】:Python内置模块
查看>>
Javascript的性能瓶颈
查看>>
annotation 不给提示
查看>>
the process cannot access the file because it is being used by another process
查看>>
2012年11月07日学习研究报告-搭建DD-WRT编译环境和刷固件的方法
查看>>
多线程1(Thread,Runnable,线程创建,线程池)
查看>>
UEditor 使用过程中问题
查看>>
iphone 常用函数汇总
查看>>
java中的CAS
查看>>
(转)Android的TextView与Html相结合的用法
查看>>
UIProgressHUD
查看>>
Powershell
查看>>
第三十三天笔记
查看>>
js正则验证之不能使用相同字符
查看>>
换字式密码
查看>>
Es6
查看>>
2013历程
查看>>
Queue
查看>>