hdu2816 I LVOE YOU TOO

I Love You Too

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


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

题目大意:第一步:将一串数字两个两个一组,每两个对应一个字母,拼音九键为对应的解码,比如:41,表示数字4上的第一个字母,即G

第二步:将键盘上的字母顺序分别对应26个字母的字典顺序        第三步:得出所需要的字母

第四步:将这段字母分成两段,再用第一段的第一个连接第二段的第一个再连接第二段的第二个,依次类推

第五步:逆序输出

#include<stdio.h>
#include<string>
#include<iostream>
#include<map>
using namespace std;
string s1, s2, si;
map<string, char>ms;
int main(){
	int t;
	//打表,直接转换到第三步 
	ms["72"] = 'A';
	ms["91"] = 'B';
	ms["32"] = 'C';
	ms["73"] = 'D';
	ms["81"] = 'E';
	ms["93"] = 'F';
	ms["82"] = 'G';
	ms["43"] = 'H';
	ms["63"] = 'I';
	ms["71"] = 'J';
	ms["21"] = 'K';
	ms["74"] = 'L';
	ms["31"] = 'M';
	ms["33"] = 'N';
	ms["41"] = 'O';
	ms["42"] = 'P';
	ms["51"] = 'Q';
	ms["52"] = 'R';
	ms["53"] = 'S';
	ms["94"] = 'T';
	ms["92"] = 'U';
	ms["23"] = 'V';
	ms["83"] = 'W';
	ms["22"] = 'X';
	ms["62"] = 'Y';
	ms["61"] = 'Z';
	while(cin >> s1){
		for(int i = 0; i < s1.size(); i=i+2){
			si.clear();
			for(int j = i; j < i+2; j++){
				si+=s1[j];
			}
			s2+=ms[si];
		}
		s1.clear();
		string s3, s4; //保存分的两端 
		t = (s2.size()+1)/2;
		for(int i = 0; i < t; i++){
			s3+=s2[i];
		}
		for(int i = t; i < s2.size(); i++){
			s4+=s2[i];
		}
		s2.clear();
		for(int i = 0; i < s3.size(); i++){
			s1 += s3[i];  //将两端交替合成一段 
			if(s4[i] != '\0')   
				s1 += s4[i];
		}
		for(int i = s1.size()-1; i >= 0; i--)
			cout << s1[i];
		cout<<endl;
		s1.clear();
	}
	return 0;
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值