Encoded Love-letter

Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 35   Accepted Submission(s) : 14
Problem Description
After Gardon had got Angel's letter, he found it was encoded...Oh my god, why did she encode a love-letter?? But don't worry, she wrote the algorithm for encoding after the letter: Each charactor are changed to a corresponding charactor. If the keyword is "Angel", the rule will be: ABCDEFGHIJKLMNOPQRSTUVWXYZ ANGELZYXWVUTSRQPOMKJIHFDCB You may find that in the bottom line, charactors of the keyword come first. All other charactors will come in a reversed order. Now given another keyword, work the letter out! Can you write a program to translate the letter?
 
Input
The letter will begin with the keyword (All uppercase), then lines of text.
 
Output
Decode the letter and print it out. Please note that a upper-case charactor will be decoded to a upper-case charactor, while a lower-case charactor will be decoded to a lower-case charactor.
 
Sample Input
ANGEL Fxlr jxaj eac W xlam cqim hqwgl W xahl kqsl kplgwat zlltwry Tlj sl atfack jxwru W eqr'j farra zqmylj cqi W mlslsnlm aj jxl eac Cqi aml atfack qr sc swre Lhlrjxqiyx W vikj gar jxwru anqij cqi Wz jxl eac wr jxl zijiml Jxwk tqhl fwtt nlgqswry jmil W'hl rlhlm gxaryl sc swre jxaj W fwtt tqhl cqi zqmlhlm W eqr'j gaml xqf zqqt wj wk W fwtt tlj sc emlas gqsl jmil W fwtt jltt cqi kqsljxwry W farra tlj cqi urqf, W tlj cqi urqf W tqhl cqi, tqhwry cqi, ak jxl sqikl tqhlk jxl mwgl Lhlr lhlmc eac xak kjqms, W fwtt atfack nc cqim kwel W swkk cqi, swkkwry cqi W eqr'j gaml xqf xame wj wk W vikj farj cqi jq nl xappc Lhlmcjxwry, W eq wj zqm cqi
 
Sample Output
When that day I hear your voice I have some special feeling Let me always think I don't wanna forget you I remember at the day You are always on my mind Eventhough I just can think about you If the day in the future This love will becoming true I've never change my mind that I will love you forever I don't care how fool it is I will let my dream come true I will tell you something I wanna let you know, I let you know I love you, loving you, as the mouse loves the rice Even every day has storm, I will always by your side I miss you, missing you I don't care how hard it is I just want you to be happy Everything, I do it for you
 
Author
DYGG
 
Source
HDU “Valentines Day” Open Programming Contest 2007-02-14

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. char c[];
  5. int main()
  6. {
  7. int n,i,sign1,sign2,j,k;
  8. char a[],b[];
  9. gets(a);
  10. sign1=strlen(a);
  11. for(i=;i<;i++)
  12. {
  13. b[i]='A'+i;
  14. b[i+]='a'+i;
  15. }
  16. for(i=;i<sign1;i++)
  17. {
  18. a[i+]=a[i]+;
  19. }
  20. for(i=sign1,j=;i<;i++,j++)
  21. {
  22. a[i]='Z'-j;
  23. a[i+]='z'-j;
  24. for(k=;k<sign1;k++)
  25. if(a[i]==a[k])
  26. {
  27. i--;break;
  28. }
  29. }
  30. while(gets(c))
  31. {
  32. sign2=strlen(c);
  33. for(i=;i<sign2;i++)
  34. {
  35. if(c[i]>='A'&&c[i]<='Z')
  36. for(k=;k<;k++)
  37. if(c[i]==a[k])
  38. {
  39. c[i]=b[k];break;
  40. }
  41. if(c[i]>='a'&&c[i]<='z')
  42. for(k=;k<;k++)
  43. if(c[i]==a[k])
  44. {
  45. c[i]=b[k];break;
  46. }
  47. }
  48. printf("%s\n",c);
  49. }
  50. return;
  51. }

Encoded Love-letter的更多相关文章

  1. B - Encoded Love-letter 字符串的处理

    B - Encoded Love-letter Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  2. CodeChef KILLKTH Killjee and k-th letter

    题意 dt { font-weight: bold; margin-top: 20px; padding-left: 35px; } dd { box-shadow: 3px 3px 6px #888 ...

  3. HDU 1591 Encoded Love-letter(简单字符串)

    Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...

  4. [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  5. Example: Encoded SNMP Message - SNMP Tutorial

    30.11 Example Encoded SNMP Message The encoded form of ASN.1 uses variable-length fields to represen ...

  6. 17. Letter Combinations of a Phone Number

    题目: Given a digit string, return all possible letter combinations that the number could represent. A ...

  7. 什么是Unicode letter

    起因:从一段代码说起 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...

  8. LeetCode——Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  9. No.017:Letter Combinations of a Phone Number

    问题: Given a digit string, return all possible letter combinations that the number could represent.A ...

随机推荐

  1. bower工具的简单使用

    基于NodeJS的一个静态资源管理工具,由twitter公司开发维,解决大型网站中静态资源的依赖问题. 1.依赖NodeJS环境和git工具. 2.npm install -g bower安装bowe ...

  2. VPS服务器利用WINSCP软件进行SFTP管理服务器文件

    虽然我使用VPS时间也不是很久,但是我善于进行统计和分析,从我在的一些VPS交流QQ群中,可以看到基本上使用搬瓦工VPS的站长群中新手较多,甚至很多人都搞不明白VPS与V-P-N的区别都直接选择VPS ...

  3. 如何在sublime中使用sass

    搞了好久,终于把sass搞定了. 最开始,我是想使用koala来实现对sass的实时编译的,但是每当我保存的时候,总是弹出erro错误,即无法编译生成css文件,百度了半天,问了好久,这个问题还是没能 ...

  4. 关于js优化和css优化

    css优化: 1.css代码的压缩. 2.css文件的合并. 3.不滥用float,因为float在渲染时计算量比较大,所以尽量减少使用float. 4.避免在html标签中写style属性. js优 ...

  5. Windows系统顽固文件删除方法

    con nul都是windows的设备,默认是不允许删除的,如果你一定要删除,可以按照以下方法进行删除!新建一个记事本输入一下内容(直接复制即可)DEL /F /A /Q \\?\%1 RD /S / ...

  6. Struts入门学习(一)

    刚开始学习框架的时候感觉很简单,都是用到javaEE的相关框架,自己就想研究源码,但是学了很久之后毫无头绪,所以还是扎扎实实学好Struts毕竟框架做起来要比自己写javaEE要简单,下面我们就来一步 ...

  7. openwrt拦截snmp报文

    SNMP使用的协议为UDP,默认端口为161和162. 使用iptables 命令如下: iptables -A INPUT -p udp -m udp --dport 161:162 -j DROP ...

  8. 关于逆波兰式的c++实现

    正常的表达式 逆波兰表达式 a+b ---> a,b,+ a+(b-c) ---> a,b,c,-,+ a+(b-c)*d ---> a,b,c,-,d,*,+ a+d*(b-c)- ...

  9. HttpReceiveRequestEntityBody 使用应注意的地方

    如果EntityBody数据很大,调用此函数是不能完全接收全部数据的,我们不能简单的判断 1: BYTE* pBuffer = new BYTE[4096]; 2: ZeroMemory(pBuffe ...

  10. kindeditor编辑器,图片上传功能齐全

    废话不多说直接上文件包压缩包:kindeditor图片上传(VS2012)