B - Encoded Love-letter

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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

 
 
 #include<cstdio>
#include<string.h>
using namespace std;
char f[]="1ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char f1[];
int ff[];
char str[];
char s[];
int main()
{
int i,j;
int len;
scanf("%s",str);
//puts(str);
getchar();
len=strlen(str);
memset(ff,,sizeof(ff));
memset(f1,,sizeof(f1));
for(i=; i<=len; i++)
{
f1[i]=str[i-];
ff[str[i-]-'A'+]=;
//printf("%d ",ff[str[i-1]-'A'+1]);
}
j=i;
for(i=; i>=; i--)
if(ff[i]==)
{
f1[j++]='A'-+i;
//printf("%c ",f1[j-1]);
}
//printf("%s",f1);
while(gets(s))
{
len=strlen(s);
for(i=;i<len;i++)
{
if(s[i]>='A'&&s[i]<='Z')
{
for(j=;j<=;j++)
if(s[i]==f1[j]) printf("%c",f[j]);
} else if(s[i]>='a'&&s[i]<='z')
{
for(j=;j<=;j++)
if(s[i]-'a'+'A'==f1[j]) printf("%c",f[j]-'A'+'a');
} //else if(s[i]==0) printf("\n");
else printf("%c",s[i]);
}
printf("\n");
} return ;
}

B - Encoded Love-letter 字符串的处理的更多相关文章

  1. Python基础->for循环、字符串以及元组

    python流程控制>for循环.字符串以及元组 学习有关序列的思想.序列:一组有顺序的东西.所有的序列都是由元素组成的,序列中的元素位置是从0开始编号的,最后一个元素的位置是它长度减一. fo ...

  2. 《think in python》学习-8

    字符串 字符串是一个序列,可以用方括号操作符来访问字符串中的单独字符 fruit = 'banana' letter = fruit[1] 方括号中的表达式称为下标 下标从0 开始 任何表达式,包括变 ...

  3. [Swift]LeetCode917. 仅仅反转字母 | Reverse Only Letters

    Given a string S, return the "reversed" string where all characters that are not a letter  ...

  4. php json_encode 返回false

    今天用ajax请求不到数据,发现问题出现在最后一句 echo json_encode($data); var_dump(json_encode($data));输出false 使用json_last_ ...

  5. 12-4 NSString

    原文:http://rypress.com/tutorials/objective-c/data-types/nsstring NSString 在本教程的内容可能我们已经看到过很多次了,NSStri ...

  6. Html5——File、FileReader、Blob、Fromdata对象

    File File 接口提供有关文件的信息,并允许网页中的JavaScript访问其内容. File对象可以用来获取某个文件的信息,还可以用来读取这个文件的内容.通常情况下,File对象是来自用户在一 ...

  7. Spring Boot项目中使用 TrueLicense 生成和验证License(服务器许可)

    一 简介 License,即版权许可证,一般用于收费软件给付费用户提供的访问许可证明.根据应用部署位置的不同,一般可以分为以下两种情况讨论: 应用部署在开发者自己的云服务器上.这种情况下用户通过账号登 ...

  8. 劳动节快乐!手写个核心价值观编码工具 - Python实现

    前言 今天是五一劳动节,祝各位无产阶级劳动者节日快乐! 然后来整活分享一些有趣的东西~ 这个小工具是我大学时做着玩的,对于各位接班人来说,12个词的核心价值观这东西,大家都非常熟悉了,这工具可以实现将 ...

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

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

随机推荐

  1. [问题2014S02] 解答

    [问题2014S02] 解答  首先注意到: 两个实系数多项式 \(f(x),g(x)\) 互素当且仅当 \(f(x),g(x)\) 在复数域 \(\mathbb{C}\) 上没有共公根, 当且仅当结 ...

  2. 151008:javascript不明白的地方

    http://www.cnblogs.com/ahthw/p/4841405.html,在这里面: function compare(num1, num2){ return num1 - num2; ...

  3. 关于SQLite数据库的作业

    数据库的SQL预览代码我忘了复制了 只能截图 Students表: Course表: Score表: Teachcer表:

  4. Kanzi入门

    1.安装Kanzi. 2.使用Kanzi studio创建工程. Kanzi创建的工程会包含以下目录结构: 其中, Tool_project文件夹中存放的是设计师设计的工程,包含kanzi UI的工程 ...

  5. javascript Demo

    var vm=(function(){ var name="jasper"; var changename=function(v){ name=v; }; return { nam ...

  6. linux 之SCP

    一.从本地到远程复制 1.复制文件 * 命令格式: 1.scp -P remote_port local_file remote_username@remote_ip:remote_folder 或者 ...

  7. window打开服务的dos命令

    window打开服务的dos命令   “开始”---> “运行”输入以下命令,或者Win + R,输入以下命令 对我比较有用的几个: 10. notepad--------打开记事本  31. ...

  8. epoll的内部实现 & 百万级别句柄监听 & lt和et模式非常好的解释

    epoll是Linux高效网络的基础,比如event poll(例如nodejs),是使用libev,而libev的底层就是epoll(只不过不同的平台可能用epoll,可能用kqueue). epo ...

  9. 如何管理linux开机自启服务

    如何管理linux开机自启服务? 自启动服务非常重要,例如 (1)需要手动添加希望自启的服务,如安装svn后没有自动添加,就需要我们手动加入(2)安装某些程序后,自动加到自启动了,但我们不需要,需要手 ...

  10. tfs 分支

    集团-IT部张强 11:15:211.主干时刻处于稳定状态,随时可以发布.设专门人员对主干代码进行管理,普通开发人员只读. 2.为开发任务建立开发分支.常规的可以以小组为单位建立分支,较大的任务可以建 ...