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. android -- 加载gif 防止oom

    项目中涉及到gif图片的展示,原来使用的是gifview,但是当频繁的,加载过大图片的时候会出现OOM的问题,后来去github上面找相关的库: https://github.com/koral--/ ...

  2. Struts2第四天

    Struts2第四天 昨天: 自定义的拦截器:继续methodFilterInterceptor,可以指定哪些方法需要拦截或者不拦截. Intercepters(配置拦截器),intercepter( ...

  3. ios 从前台返回到回台 从后台返回到前台 或者 支付宝支付订单后 对界面进行操作

    正常情况下,在AppDelegate中实现下面两个方法,能够监听从后台恢复到前台 - (void)applicationDidEnterBackground:(UIApplication *)appl ...

  4. String类之indexOf--->查找某字对应的位置

    以下方法都是java内置类String类的内置方法(不是构造方法哦,就是普通的方法),不需要我们写,直接拿过来用即可. indexOf方法对应Api介绍 lastIndexOf方法对应Api介绍 -- ...

  5. JavaScript 运动框架 Step by step(转)

    1,运动原理 Js运动,本质来说,就是让 web 上 DOM 元素动起来.而想要 DOM 动起来,改变其自身的位置属性,比如高宽,左边距,上边距,透明度等.动画的原理就是把不同状态的物体,串成连续的样 ...

  6. iOS开发瀑布流的实现

    //自定义布局,继承于UICollectionViewLayout #import <UIKit/UIKit.h> @class WaterFlowLayout; @protocol  W ...

  7. thinkphp 匹配qq 表情

    <?php// 匹配qq表情    function replace_phiz($content){        preg_match_all('/\[.*?\]/is',$content,$ ...

  8. Java 反射 设计模式 动态代理机制详解 [ 转载 ]

    Java 反射 设计模式 动态代理机制详解 [ 转载 ] @author 亦山 原文链接:http://blog.csdn.net/luanlouis/article/details/24589193 ...

  9. 用户id有则更新,无则添加 使用replace into (代替 insert into)

    app登录成功后,调用后台,更新channel_id public function set_pushchannel($device,$channelid,$iv='' ) $sql = " ...

  10. AOV网

    1.定义 用顶点表示活动,用有向边<Vi, Vj>表示活动间的优先关系. Vi必须先于活动Vj进行. 这种有向图叫做顶点表示活动的AOV网络(Activity On Vertices) 2 ...