2014
02-17

# I Love You Too

This is a true story. A man showed his love to a girl,but the girl didn’t replied clearly ,just gave him a Morse Code:
****-/*—-/—-*/****-/****-/*—-/—**/*—-/****-/*—-/-****/***–/****-/*—-/—-*/**—/-****/**—/**—/***–/–***/****-/   He was so anxious that he asked for help in the Internet and after one day a girl named "Pianyi angel" found the secret of this code. She translate this code as this five steps:
1.First translate the morse code to a number string:4194418141634192622374
2.Second she cut two number as one group 41 94 41 81 41 63 41 92 62 23 74,according to standard Mobile phone can get this alphabet:GZGTGOGXNCS

3.Third she change this alphabet according to the keyboard:QWERTYUIOPASDFGHJKLZXCVBNM = ABCDEFGHIJKLMNOPQRSTUVWXYZ
So ,we can get OTOEOIOUYVL
4.Fourth, divide this alphabet to two parts: OTOEOI and OUYVL, compose again.we will get OOTUOYEVOLI
5.Finally,reverse this alphabet the answer will appear : I LOVE YOU TOO

I guess you might worship Pianyi angel as me,so let’s Orz her.
Now,the task is translate the number strings.

A number string each line(length <= 1000). I ensure all input are legal.

A number string each line(length <= 1000). I ensure all input are legal.

4194418141634192622374
41944181416341926223

ILOVEYOUTOO
VOYEUOOTIO

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
char num[9][4] = {{' ', ' ', ' ', ' '}, {'A', 'B', 'C', ' '},{'D', 'E', 'F', ' '},{'G', 'H', 'I', ' '},{'J', 'K', 'L', ' '},{'M', 'N', 'O',' '},{'P', 'Q', ' R', 'S'},{'T', 'U', 'V', ' '},{'W', 'X', 'Y', 'Z'}};
string a = "QWERTYUIOPASDFGHJKLZXCVBNM";
string b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

char fun(char c)
{
for(int i = 0; i < 52; ++i)
if(a[i] == c)
return b[i];
}

int main()
{
char p[1010];
string s, t, qian, hou, res;
bool flag;
int len, t1;
while(~scanf("%s", p))
{
len = strlen(p);
flag = true;
s.clear(); t.clear(); qian.clear(); hou.clear(); res.clear();
for(int i = 0; i < len; i += 2)
s += num[(p[i] - '0') - 1][(p[i + 1] - '0') - 1];
len = s.length();
t1 = len;
for(int i = 0; i < len; ++i)
t += fun(s[i]);
qian = t.substr(0, (len + 1) / 2);
hou = t.substr((len + 1) / 2);
len = qian.length();
int len1 = hou.length();
for(int i = 0, j = 0; i < len && j < len1; ++i, ++j)
{
res += qian[i];
res += hou[j];
}
if(t1 % 2)
res += qian[len - 1];
for(int i = len + len1 - 1; i >= 0; --i)
cout<<res[i];
cout<<endl;
}
return 0;
}

1. #include <cstdio>
#include <cstring>

const int MAXSIZE=256;
//char store[MAXSIZE];
char str1[MAXSIZE];
/*
void init(char *store) {
int i;
store['A']=’V', store['B']=’W',store['C']=’X',store['D']=’Y',store['E']=’Z';
for(i=’F';i<=’Z';++i) store =i-5;
}
*/
int main() {
//freopen("input.txt","r",stdin);
//init(store);
char *p;
while(fgets(str1,MAXSIZE,stdin) && strcmp(str1,"STARTn")==0) {
if(p=fgets(str1,MAXSIZE,stdin)) {
for(;*p;++p) {
//*p=store[*p]
if(*p<’A’ || *p>’Z') continue;
if(*p>’E') *p=*p-5;
else *p=*p+21;
}
printf("%s",str1);
}
fgets(str1,MAXSIZE,stdin);
}
return 0;
}