An implicit love letter

Source: Internet
Author: User

1714: Implicit love letter Time limit: 1 Sec Memory Limit: MB
Submit: 211 Solved: 61

Submitstatusweb Board Description

How can love letters be more subtle? I'll teach you. First you need a few 4*4 forms, and then fill in the words you want to write. For example: What you want to say is "Abcdefghijklmnopqrstu" (shen me GUI), then fill in the form like this:
First sheet:
ABCD
EFGH
IJKL
Mnop
Second sheet:
Qrst
u---
----
----
since this paragraph is more than 16 words long, so fill in two tables, if longer use more tables, the end of the idle place with '-' to fill.
and then the wonderful place came. You tell the sister the password. There are three kinds of password, 123 means, three kinds of passwords correspond to different encryption methods. Here are three kinds of passwords are encrypted separately, simple observation you will find the law of encryption.
1:mieanjfbokgcplhd--uq---R---s---t
2:PONMLKJIHGFEDCBA-----------Utsrq
3:DHLPCGKOBFJNAEIMT---s---r---qu--
Well, I'm sure you've learned the technology. A new batch of primary school sister will be "incoming", the number of Ah, love letter encryption work is more difficult, please everyone to help.

Input

Multiple sets of test data
Each set of test data has two rows,
First row one number K (1 <= k <= 3), which means encryption
The second line represents the encrypted love letter (consisting of uppercase and lowercase letters, numbers, spaces, and lengths not exceeding 100)

Output

For each set of test data, output encrypted ciphertext.

Sample Input1abcdefghijklmnopqrstu2a b c D 0 1 2 3 4Sample OutputMieanjfbokgcplhd--uq---R---s---T 3 2 1 0 d C b a---------------4HINT

Source

Harbin University of Technology Fifth annual ACM Program Design Contest (Warm up)

Although the water problem, but spent a lot of time. I'm looking for a problem when I find the character in the D array to give an array, I've been looking for something wrong. It's finally done.

#include <iostream> #include <string.h>using namespace Std;int main () {int k,i,j,len,g,flag;    Char d[110];    Char a[28][4];        while (scanf ("%d", &k)!=eof) {GetChar ();      Gets (d);      flag=0;      for (i=0;i<28;i++) {for (j=0;j<4;j++) a[i][j]= '-';            } len=strlen (d);        g=0;                for (i=0;i<28;i++) {for (j=0;j<4;j++) {a[i][j]=d[g++];                    if (G==len) {flag=1;                Break        }} if (flag) break;                } if (k==1) {if (len%16==0)//3 7 {for (g=1;g<=len/16;g++)            for (j=0;j<4;j++) for (i=4*g-1;i>=4*g-4;i--) cout<<a[i][j];      } else {for (g=1;g<=len/16+1;g++) for (j=0;j<4;j++)            for (i=4*g-1;i>=4*g-4;i--) cout<<a[i][j]; }} else if (k==2) {if (len%16==0)//3 7 {for (g=1;g<=len/16;g++ ) for (i=4*g-1;i>=4*g-4;i--) for (j=3;j>=0;j--) cout<<a[i][j            ];                  } else {for (g=1;g<=len/16+1;g++) for (i=4*g-1;i>=4*g-4;i--)        for (j=3;j>=0;j--) cout<<a[i][j]; }} else if (k==3) {if (len%16==0)//3 7 {for (g=1;g<=len/16;g+ +) for (j=3;j>=0;j--) for (i=4*g-4;i<=4*g-1;i++) COUT&LT;&L            T;A[I][J]; } else {for (g=1;g<=len/16+1;g++) for (j=3;j>=0;j--) F or (i=4*g-4;i<=4*g-1;i++) cout<<a[i][j];    }} cout<<endl; } return 0;}

An implicit love letter

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.