HDU 1591 Encoded Love-letter(简单字符串)
2017-01-17 10:07
459 查看
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1780 Accepted Submission(s): 635
[align=left]Problem Description[/align]
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?
[align=left]Input[/align]
The letter will begin with the keyword (All uppercase), then lines of text.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
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
[align=left]Sample Output[/align]
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
Total Submission(s): 1780 Accepted Submission(s): 635
[align=left]Problem Description[/align]
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?
[align=left]Input[/align]
The letter will begin with the keyword (All uppercase), then lines of text.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
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
[align=left]Sample Output[/align]
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<stdio.h> #include<string.h> #include<algorithm> using namespace std; char sh[1100],s[1100]; char c; int i,j,k,l,m,n; void ac(char sh[]) { l=strlen(sh); for(i=0;i<l;i++) if(sh[i]>='a'&&sh[i]<='z') sh[i]-=32;//先变成大写 for(i=0;i<l;i++) s[i]=sh[i]; int flag=25; for(i=25;i>=0;i--)//得到密码字符串 { for(j=0;j<l;j++) if('Z'-i==sh[j]) break; if(j==l) s[flag--]='Z'-i; } } int main() { scanf("%s",sh); getchar(); ac(sh); while(scanf("%c",&c)!=EOF)//逐个字母输入 { for(i=0;i<26;i++) { if(c==s[i]) { printf("%c",'A'+i); break; } if(c==s[i]+32) { printf("%c",'a'+i); break; } } if(i==26) printf("%c",c); } }
相关文章推荐
- 随时间变化的瞬时频率
- python下如何查询CS反恐精英的服务器信息
- H.264句法和语法总结(十三)残差句法
- 去掉html标签和所有空格
- Ubuntu16.04 升级内核至4.8
- linux学前小结
- java中HashSet的add的使用,以及equals和hashcode的重写
- Fiddler自动响应AutoResponder正则匹配
- 【linux】Linux学习总结-套接字
- jboss7开发配置指南
- 算法库的重要性
- 详解通过Nginx部署Django(基于ubuntu)
- execute、executeUpdate、executeQuery三者的区别(及返回值)
- 查看linux ssh服务信息及运行状态
- Java正则表达式详解(Pattern类和Matcher类)
- log4j笔记
- asp.net 查询sql数据表的网页模板
- H.264句法和语法总结(十二)子宏块预测句法
- RecyclerView+index索引实现仿微信通讯录
- python基础教程之匿名函数lambda