HDU 1591 encoded Love-letter (simple String)

Source: Internet
Author: User

Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total Submission (s): 1780 Accepted submission (s): 635


Problem Descriptionafter 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 is changed to a corresponding Charactor. If The keyword is "Angel", the rule would be:

Abcdefghijklmnopqrstuvwxyz
Angelzyxwvutsrqpomkjihfdcb

you'll find the bottom line, charactors of the keyword come First. All other charactors would come in a reversed order.

Now given another keyword, work the letter out!
Can you write a program to translate?

Inputthe letter would begin with the keyword (all Uppercase) and then lines of Text.

Outputdecode the letter and print it Out. Please note that a upper-case charactor is decoded to a upper-case charactor and while a lower-case charactor would be de Coded to a lower-case charactor.

Sample INPUTANGELFXLR Jxaj EAC w xlam cqim hqwglw Xahl kqsl kplgwat zlltwrytlj sl atfack jxwru W eqr ' J Farra zqmylj CqiW m LSLSNLM AJ JXL eaccqi AML atfack qr SC swrelhlrjxqiyx W vikj gar jxwru anqij cqiwz jxl EAC WR jxl zijimljxwk TQHL FWTT NLG Qswry 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 urqf W 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 XAPPCLHLMC jxwry, W eq WJ zqm CQI

Sample Outputwhen that day I hear your voicei has some special feelinglet me always think I don ' t wanna forget YouI REMEM ber at the dayyou is always on my mindeventhough I just can think about youif the day in the Futurethis love would becomin G Truei ' ve never change my mind that I'll love you foreveri don ' t care how fool it IsI would let my dream come truei would Tell me something I wanna let's know, I let you know I love you, loving you, as the mouse loves the Riceeven Has storm, I'll always by your sidei Miss you, missing YouI don ' t care how hard it's I just want you to be Happyeveryt hing, I do it for you

1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 Charsh[1100],s[1100];6 Charc;7 inti,j,k,l,m,n;8 voidAcCharSh[])9 {TenL=strlen (sh); one      for(i=0; i<l;i++) a     if(sh[i]>='a'&&sh[i]<='Z') -sh[i]-= +;//Capitalize first -      for(i=0; i<l;i++) thes[i]=sh[i]; -     intflag= -; -      for(i= -; i>=0; i--)//get the password string -     { +          for(j=0; j<l;j++) -         if('Z'-i==Sh[j]) +          break; a         if(j==L) ats[flag--]='Z'-i; -     } - } - intMain () - { -scanf"%s", sh); in GetChar (); - AC (sh); to      while(SCANF ("%c", &c)!=eof)//Enter by letter +     { -          for(i=0;i< -; i++) the         { *             if(c==s[i]) $             {Panax Notoginsengprintf"%c",'A'+i); -                  break; the             } +              a             if(c==s[i]+ +) the             { +printf"%c",'a'+i); -                  break; $             } $         } -             if(i== -) -printf"%c", c); the     } -}

HDU 1591 encoded Love-letter (simple String)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.