E - I Love You Too解题报告

E - I Love You Too
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

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.
 

Input

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

Output

An upper alphabet string.
 

Sample Input

       
       
4194418141634192622374 41944181416341926223
 

Sample Output

       
       
ILOVEYOUTOO VOYEUOOTIO
 

这个题最麻烦的是数组的初始化,不过还好一次ac。


[html]  view plain copy
  1. #include<iostream>  
  2. using namespace std;  
  3. int main()  
  4. {  
  5.     char a[10][5],b[1000],c[200],e[1000],f[1000];  
  6.     int num,sum,n,m,i,j=0,s,j1;  
  7.     a[2][1]='A';a[2][2]='B';a[2][3]='C';a[3][1]='D';a[3][2]='E';a[3][3]='F';  
  8.     a[4][1]='G';a[4][2]='H';a[4][3]='I';a[5][1]='J';a[5][2]='K';a[5][3]='L';  
  9.     a[6][1]='M';a[6][2]='N';a[6][3]='O';a[7][1]='P';a[7][2]='Q';a[7][3]='R';  
  10.     a[7][4]='S';a[8][1]='T';a[8][2]='U';a[8][3]='V';a[9][1]='W';a[9][2]='X';  
  11.     a[9][3]='Y';a[9][4]='Z';  
  12.     c['Q']='A';c['W']='B';c['E']='C';c['R']='D';c['T']='E';c['Y']='F';  
  13.     c['U']='G';c['I']='H';c['O']='I';c['P']='J';c['A']='K';c['S']='L';  
  14.     c['D']='M';c['F']='N';c['G']='O';c['H']='P';c['J']='Q';c['K']='R';  
  15.     c['L']='S';c['Z']='T';c['X']='U';c['C']='V';c['V']='W';c['B']='X';  
  16.     c['N']='Y';c['M']='Z';  
  17.     while(cin>>b)  
  18.     {  
  19.         j=0;  
  20.         j1=0;  
  21.         s=strlen(b);  
  22.         for(i=0;i<s-1;i=i+2)  
  23.         {  
  24.             j++;  
  25.             m=b[i]-'0';  
  26.             n=b[i+1]-'0';  
  27.             e[j]=c[a[m][n]];  
  28.         }  
  29.         if(j%2==0)  
  30.             num=j/2;  
  31.         else  
  32.             num=j/2+1;  
  33.         m=num+1;  
  34.         for(n=1;n<=num;n++)  
  35.         {  
  36.             f[j1]=e[n];  
  37.             j1++;  
  38.             if(m<=j)  
  39.             {   f[j1]=e[m];  
  40.             j1++;  
  41.             m++;}  
  42.         }  
  43.         for(i=j-1;i>=0;i--)  
  44.             printf("%c",f[i]);  
  45.         cout<<endl;  
  46.     }  
  47.     return 0;  
  48. }  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值