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. @Scheduled(cron = "0 0 * * * ?")实现定时任务

    //每一个小时执行一次 @Scheduled(cron = "0 0 * * * ?") public void saveDailyScoreScheduled() { try { ...

  2. JavaScript input框输入实时校验

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  3. 第五十五节,IO多路复用select模块加socket模块,伪多线并发

    IO多路复用select模块加socket模块,伪多线并发,并不是真正的多线程并发,实际通过循环等待还是一个一个处理的 IO多路复用,lo就是文件或数据的输入输出,IO多路复用就是可以多用户操作 IO ...

  4. 火狐中,设置align="center"失效的解决方法

    如下: <img align="center" style="vertical-align:top"></img> 只需要加上: ver ...

  5. apache动态编译与静态编译

    静态: 在使用./configure 编译的时候,如果不指定某个模块为动态,即没有使用:enable-mods-shared=module或者enable-module=shared 这个2个中的一个 ...

  6. PHP class which generates PDF files from UTF-8 encoded HTML

    http://www.mpdf1.com/mpdf/index.php

  7. 关于springboot启动时候报错:springboot Failed to parse configuration class [Application]

    把运行的java类放在一个package下后就不再提示这个错误. 使用的ide是intellij,之前也有因为没有创建package报错的经历,可能这是intellij必须的

  8. ***参考Catch That Cow(BFS)

    Catch That Cow Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Tot ...

  9. 网络传输中的三张表,MAC地址表、ARP缓存表以及路由表

    一:MAC地址表详解 说到MAC地址表,就不得不说一下交换机的工作原理了,因为交换机是根据MAC地址表转发数据帧的.在交换机中有一张记录着局域网主机MAC地址与交换机接口的对应关系的表,交换机就是根据 ...

  10. Asynchronous JS: Callbacks, Listeners, Control Flow Libs and Promises

    非常好的文章,讲javascript 的异步编程的. ------------------------------------------------------------------------- ...