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

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
char c[];
int main()
{
int n,i,sign1,sign2,j,k;
char a[],b[];
gets(a);
sign1=strlen(a);
for(i=;i<;i++)
{
b[i]='A'+i;
b[i+]='a'+i;
}
for(i=;i<sign1;i++)
{
a[i+]=a[i]+;
}
for(i=sign1,j=;i<;i++,j++)
{
a[i]='Z'-j;
a[i+]='z'-j;
for(k=;k<sign1;k++)
if(a[i]==a[k])
{
i--;break;
}
}
while(gets(c))
{
sign2=strlen(c);
for(i=;i<sign2;i++)
{
if(c[i]>='A'&&c[i]<='Z')
for(k=;k<;k++)
if(c[i]==a[k])
{
c[i]=b[k];break;
}
if(c[i]>='a'&&c[i]<='z')
for(k=;k<;k++)
if(c[i]==a[k])
{
c[i]=b[k];break;
}
}
printf("%s\n",c);
}
return;
}

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. @NotNull和@NotEmpty和@NotBlank区别

    1.@NotNull:不能为null,但可以为empty (""," "," ") 2.@NotEmpty:不能为null,而且长度必须大于 ...

  2. python文件操作_对文件进行复制拷贝_代码实现

    要求: 1,对已经存在的文件进行复制操作 2,复制后的文件在文件名后面加上[复件] 3,文件比较大如何优化处理 #-*- coding: UTF-8 -*- #这是python 2 下面写的,用的ra ...

  3. Android:内存优化的一些总结

    ______________________摘录于:http://www.cnblogs.com/yezhennan/p/5442557.html____________________ 1.大图片的 ...

  4. 重读The C programming Lanuage 笔记四:c预处理

    C预处理器执行宏替换.条件编译以及包含指定的文件.以#开头的命令行就是与处理器的对象.这些命令行的语法独立于语言的其他部分,它们可以出现在任何地方,其作用可延续到所在编译单元的末尾(与作用域无关).行 ...

  5. Oracle截取某字段前后字符串

    创建测试表及数据 1 2 3 4 5 6 7 8 9 create table test (name varchar2(10));   insert into test values ('2-15') ...

  6. MVC创建

    [1]创建ASP.NET_MVC应用程序   1>新建项目>web>Visual Studio 2012>ASP.NET MVC4 Web应用程序   2>填写名称,位置 ...

  7. Python查询MySQL进行远程采集图片实例

    这是四五年以前做小说站采集图片时写过唯一一次 Python 代码 #!/usr/bin/python #-*-coding:utf-8-*- import MySQLdb, os, socket, t ...

  8. 第九十节,html5+css3pc端固定布局,底部区域,说明区域,版权区域

    html5+css3pc端固定布局,底部区域,说明区域,版权区域 完成: HTML代码: <!--尾部--> <footer class="wei-bu"> ...

  9. jQuery复习:第二章&第三章

    第二章 一.选择器 1.层次选择器 $(“ancestor descendant”)选取ancestor元素里的所有后代元素 $(“parent > child”)选取parent元素下的chi ...

  10. php的实参和形参

    1.实参是调用函数时候的参数; 2.形参是声明函数时侯的参数, 例如 public function demo($a,$b) {         return ; } 如果声明的函数如上,调用时dem ...