hdu-2816-I Love You Too

I Love You Too

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1552 Accepted Submission(s): 937


Problem 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
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
struct in
{
    char b[4];
}a[10];
char c[1005],d[1005];
int main()
{
    a[2].b[0]='A',a[2].b[1]='B',a[2].b[2]='C';//={'A','B','C'};
    a[3].b[0]='D',a[3].b[1]='E',a[3].b[2]='F';//a[3].b[4]={'D','E','F'};
    a[4].b[0]='G',a[4].b[1]='H',a[4].b[2]='I';//a[4].b[4]={'G','H','I'};
    a[5].b[0]='J',a[5].b[1]='K',a[5].b[2]='L';//a[5].b[4]={'J','K','L'};
    a[6].b[0]='M',a[6].b[1]='N',a[6].b[2]='O';//a[6].b[4]={'M','N','O'};
    a[7].b[0]='P',a[7].b[1]='Q',a[7].b[2]='R',a[7].b[3]='S';//a[7].b[4]={'P','Q','R','S'};
    a[8].b[0]='T',a[8].b[1]='U',a[8].b[2]='V';//a[8].b[4]={'T','U','V'};
    a[9].b[0]='W',a[9].b[1]='X',a[9].b[2]='Y',a[9].b[3]='Z';//a[9].b[4]={'W','X','Y','Z'};
    int i,j,k;
    while(scanf("%s",c)!=EOF)
    {
        k=0;
        for(i=0;i<strlen(c);i+=2)
            d[k++]=a[c[i]-'0'].b[c[i+1]-'0'-1];
            //printf("%s\n",d);
        for(i=0;i<k;i++)
        {
            switch(d[i])
        {
        case 'Q':
            d[i]='A';break;
        case 'W':
            d[i]='B';break;
        case 'E':
            d[i]='C';break;
        case 'R':
            d[i]='D';break;
        case 'T':
            d[i]='E';break;
        case 'Y':
            d[i]='F';break;
        case 'U':
            d[i]='G';break;
        case 'I':
            d[i]='H';break;
        case 'O':
            d[i]='I';break;
        case 'P':
            d[i]='J';break;
        case 'A':
            d[i]='K';break;
        case 'S':
            d[i]='L';break;
        case 'D':
            d[i]='M';break;
        case 'F':
            d[i]='N';break;
        case 'G':
            d[i]='O';break;
        case 'H':
            d[i]='P';break;
        case 'J':
            d[i]='Q';break;
        case 'K':
            d[i]='R';break;
        case 'L':
            d[i]='S';break;
        case 'Z':
            d[i]='T';break;
        case 'X':
            d[i]='U';break;
        case 'C':
            d[i]='V';break;
        case 'V':
            d[i]='W';break;
        case 'B':
            d[i]='X';break;
        case 'N':
            d[i]='Y';break;
        case 'M':
            d[i]='Z';break;
        }
        }
       // printf("%s\n",d);
        int t=0;
        if(k%2!=0)
        {
            for(i=0,j=k/2+1;i<=k/2;i++,j++)
        {
            c[t++]=d[i];
            if(d[j]>='A'&&d[j]<='Z')
               c[t++]=d[j];
        }
        }
        else
        {
            for(i=0,j=k/2;i<k/2;i++,j++)
        {
            c[t++]=d[i];
            if(d[j]>='A'&&d[j]<='Z')
               c[t++]=d[j];
        }
        }
        for(i=t-1;i>=0;i--)
        printf("%c",c[i]);
        printf("\n");
        memset(c,'0',sizeof(c));
        memset(d,'0',sizeof(d));
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值