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.
 #include <stdio.h>
#include <string.h>
#define maxn 10000
int main()
{
#ifdef CLOCK
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
int i;
#ifdef LOCAL
FILE * fin,* fout;
fin = fopen("data.in", "rb");
fout = fopen("data.out", "wb");
#endif
char buf[maxn];
memset(buf, , sizeof(buf));
while (fgets(buf, sizeof(buf), stdin))
{
for (i = ; i < strlen(buf); i++)
buf[i] -= ;
buf[i - 1] = '\0';
printf("%s\n", buf);
}
#ifdef LOCAL
fclose(fin);
fclose(fout);
#endif
return ;
}

报告:还是比较顺的解决了,只是其中因为\r\n的问题纠结一下,strlen的长度实际是指到'\0',且包括\n,即题中buf[i]为'\0',buf[i-1]为'\n'。而当用到fprintf时,printf("%s\n", buf);改为fprintf("%s\r\n", buf);即后面需要加上\r\n来实现换行。

问题:无

解决:无

 

UVa OJ 458的更多相关文章

  1. uva oj 567 - Risk(Floyd算法)

    /* 一张有20个顶点的图上. 依次输入每个点与哪些点直接相连. 并且多次询问两点间,最短需要经过几条路才能从一点到达另一点. bfs 水过 */ #include<iostream> # ...

  2. UVa OJ 194 - Triangle (三角形)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 A triangle is a basic shape of planar geometry. It con ...

  3. UVa OJ 175 - Keywords (关键字)

    Time limit: 3.000 seconds限时3.000秒 Problem问题 Many researchers are faced with an ever increasing numbe ...

  4. UVa OJ 197 - Cube (立方体)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 There was once a 3 by 3 by 3 cube built of 27 smaller ...

  5. UVa OJ 180 - Eeny Meeny

    Time limit: 3.000 seconds限时3.000秒 Problem问题 In darkest <name of continent/island deleted to preve ...

  6. UVa OJ 140 - Bandwidth (带宽)

    Time limit: 3.000 seconds限时3.000秒 Problem问题 Given a graph (V,E) where V is a set of nodes and E is a ...

  7. 548 - Tree (UVa OJ)

    Tree You are to determine the value of the leaf node in a given binary tree that is the terminal nod ...

  8. UVa OJ 10300

    Problem A Ecological Premium Input: standard input Output: standard output Time Limit: 1 second Memo ...

  9. UVa OJ 10071

    Problem B Back to High School Physics Input: standard input Output: standard output A particle has i ...

随机推荐

  1. 请问snmp到底是干啥的。

    这个事情分两方面来说:首先是路由器这部分.路由器开启SNMP功能之后,它能够对自己的每个接口上的流量有一个统计,当然统计的不单单只有流量.然后路由器把统计到的内容按一定的格式保存起来.这个格式是大家都 ...

  2. WAS域名解析问题

    1.如果dmgr和his在一台机器上,但web服务器用的是app服务器 如下图: 插件都处理完成. 这时候,通过外网域名访问时,出现如下情况 或者 说明:ihs服务器上webserver1的文件Plu ...

  3. JSON详解+ C# String.Format格式说明+ C# ListView用法详解 很完整

    JSON详解 C# String.Format格式说明 C# ListView用法详解 很完整

  4. AutoIt: send 命令 VS ControlClick的使用

    2008年的时候第一次接触AutoIt,当时觉得局限性太多了,就不想学,觉得把Watir,Ruby搞好就行了. 最近一段时间比较闲,发现自己对GUI的自动化操完全是短板,就把AutoIt重新拾起来了. ...

  5. explain之二:Explain 结果解读与实践,分析诊断工具之二

    MySQL的EXPLAIN命令用于SQL语句的查询执行计划(QEP).这条命令的输出结果能够让我们了解MySQL 优化器是如何执行SQL 语句的.这条命令并没有提供任何调整建议,但它能够提供重要的信息 ...

  6. 国产spfa瞎几把嗨

    //在各种不利的因素下,我居然就这么水过了这题最短路,然而还wa了一次,因为路是双向的... //这题姿势很多啊,但自从会了国产spfa就是最短路能搞的就是spfa,优点太多了!!! //也是瞎几把打 ...

  7. bzoj 4622: [NOI 2003] 智破连环阵【dfs+匈牙利算法】

    一个炸弹炸一个区间的武器,想到二分图匹配 但是直接dfs断点显然不行,预处理出dis[i]为i到m的至多值来最优性剪枝,并且标记ok[i][j]为炸弹i可以炸到j武器,mx[i][j]为i炸弹从j武器 ...

  8. P1251 递推专练3

    递推专练3 描述 Description 圆周上有N个点.连接任意多条(可能是0条)不相交的弦(共用端点也算相交)共有多少种方案? 输入格式 Input Format 读入一个数N.<=N< ...

  9. 调试的时候禁止chrome缓存图片

    https://blog.csdn.net/yiifaa/article/details/54290047 https://blog.csdn.net/xinghuo0007/article/deta ...

  10. 在IDEA中使用JSP中的out内置对象,out.println()——println红色解决方法

    今天在学习JSP的时候,在jsp中使用out内置对象,开发工具用的是IDEA,结果如下图所示 郁闷了半天找度娘,可能关键字输的不准确,乱七八糟的方法一大堆,什么加依赖啊啥的,反正都不管用,最后找到一篇 ...