WOJ1141-Encoded Love-letter
来源:互联网 发布:vb可执行文件的扩展名 编辑:程序博客网 时间:2024/05/22 08:26
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?
输入格式
The letter will begin with the keyword (All uppercase), then lines of text.
输出格式
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.
样例输入
ANGELFxlr jxaj eac W xlam cqim hqwglW xahl kqsl kplgwat zlltwryTlj sl atfack jxwru W eqr'j farra zqmylj cqiW mlslsnlm aj jxl eacCqi aml atfack qr sc swreLhlrjxqiyx W vikj gar jxwru anqij cqiWz jxl eac wr jxl zijimlJxwk tqhl fwtt nlgqswry jmilW'hl rlhlm gxaryl sc swre jxaj W fwtt tqhl cqi zqmlhlmW eqr'j gaml xqf zqqt wj wkW fwtt tlj sc emlas gqsl jmilW fwtt jltt cqi kqsljxwry W farra tlj cqi urqf, W tlj cqi urqfW tqhl cqi, tqhwry cqi, ak jxl sqikl tqhlk jxl mwglLhlr lhlmc eac xak kjqms, W fwtt atfack nc cqim kwelW swkk cqi, swkkwry cqiW eqr'j gaml xqf xame wj wkW vikj farj cqi jq nl xappcLhlmcjxwry, W eq wj zqm cqi
样例输出
When that day I hear your voiceI have some special feelingLet me always think I don't wanna forget youI remember at the dayYou are always on my mindEventhough I just can think about youIf the day in the futureThis love will becoming trueI've never change my mind that I will love you foreverI don't care how fool it isI will let my dream come trueI will tell you something I wanna let you know, I let you knowI love you, loving you, as the mouse loves the riceEven every day has storm, I will always by your sideI miss you, missing youI don't care how hard it isI just want you to be happyEverything, I do it for you
按照置换的方法套回去就可以
#include<stdio.h>#include<string.h>char key[27];int decode[26];int letter[26];char c;int main(){scanf("%s",&key);int i,l=strlen(key),t;memset(letter,0,sizeof(letter));for(i=0;i<l;i++){t=key[i]-'A';letter[t]=1;decode[i]=t;}t=26;for(;i<26;i++){while(t--){if(letter[t]==0)break;}decode[i]=t;}for(i=0;i<26;i++){letter[decode[i]]=i;}/*for(i=0;i<26;i++){printf("%c",'A'+decode[i]);}*/getchar();while(scanf("%c",&c)!=EOF){if(c>='a'&&c<='z')printf("%c",'a'+letter[c-'a']);else if(c>='A'&&c<='Z')printf("%c",'A'+letter[c-'A']);elseprintf("%c",c);} return 0;}
- WOJ1141-Encoded Love-letter
- HDU1591-Encoded Love-letter
- hdu---1591Encoded Love-letter
- HDU 1591 Encoded Love-letter
- HDU ACM 1591 Encoded Love-letter
- 杭电1591 hdu 1591 Encoded Love-letter
- love Letter
- Love Letter
- fjnu 1636 Love letter
- A Love Letter
- A Love Letter
- A Love Letter
- XTU_1184 A Love Letter
- A Love Letter For You
- Love Letter(海角七号)
- A Love Letter To Josephine
- hackerrank The Love-Letter Mystery
- Love Letter源程序 与程序分析
- 机器学习实战:KNN算法
- c++冒泡排序
- opaque integer resource pod.alpha.kubernetes.io/opaque-int-resource- 自定义资源类型
- Spring集成Hibernate5_02-HibernateTemplate
- 将本地文件上传到Linux目录下(上传到vm虚拟机中)
- WOJ1141-Encoded Love-letter
- Red Hat NGINX 自启动
- web 前端基础知识精简
- POJ 2195 Going Home(最小费用最大流)
- Mysql 排序原理
- 杭电ACM1000
- Python报错信息与原因分析
- /usr/local/lib/libpython2.7.a: could not read symbols: Bad value. collect2: ld retur ned 1 exit
- jquery+css实现下拉列表