HDU - 2816 I Love You Too(水)
来源:互联网 发布:淘宝的火麻叶是真的么 编辑:程序博客网 时间:2024/05/17 08:38
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.
****-/*----/----*/****-/****-/*----/---**/*----/****-/*----/-****/***--/****-/*----/----*/**---/-****/**---/**---/***--/--***/****-/ 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
419441814163419262237441944181416341926223
Sample Output
ILOVEYOUTOOVOYEUOOTIO
水水的~~ ~~
敲代码的时候,时不时把重要的变量打印出来是一件很好的事情。
#include<iostream>using namespace std;const char dig[12][6] = { "0", "_", "0ABC", "0DEF", "0GHI", "0JKL", "0MNO", "0PQRS", "0TUV", "0WXYZ" };const char all[30] = "QWERTYUIOPASDFGHJKLZXCVBNM";int main(){char digi[1010];while (cin >> digi){char al[1010]="0";int len = strlen(digi);for (int i = 0; i < len/2; i++){al[i] = dig[digi[i * 2]-'0'][digi[i * 2 + 1]-'0'];}/*for (int i = 0; i < len / 2; i++)cout << al[i] << " ";cout << endl;*/for (int i = 0; i < len / 2; i++){for (int j = 0; j <= 26;j++)if (al[i] == all[j]){al[i] = 'A' + j; break;}}/*for (int i = 0; i < len / 2; i++)cout << al[i] << " ";cout << endl;*/char ans[1010];for (int i = 0; i < (len / 2+1)/2; i++){ans[i * 2] = al[i];}for (int i = (len / 2 + 1) / 2,j=0; i < len / 2; i++, j++){ans[j * 2+1] = al[i];}/*for (int i = 0; i < len / 2; i++)cout << ans[i] << " ";cout << endl;*/char ans2[1010] = { 0 };for (int i = 0; i < len / 2; i++)ans2[i] = ans[len / 2 - 1 - i];/*for (int i = 0; i < len / 2; i++)cout << ans2[i] << " ";cout << endl;*/ans2[len / 2] = '\0';cout << ans2 << endl;}}
0 0
- HDU - 2816 I Love You Too(水)
- hdu 2816 I Love You Too
- HDU-2816 I Love You Too【字符串】
- HDU 2816 I Love You Too
- HDU---2816 I LOVE YOU TOO
- hdu-2816 I Love You Too
- HDU 2816 ( I Love You Too )
- hdu 2816 I Love You Too
- hdu-2816-I Love You Too
- 杭电ACM HDU 2816 I Love You Too
- hdu——2816——I Love You Too
- hdu杭电 2816 I Love You Too
- HDU 2816 I Love You Too [Ad Hoc]
- I Love You Too
- I Love You Too
- I Love You Too 2816 (字符串 好题)
- hd2816 I Love You Too
- hdoj 2816 I Love You Too 【模拟题】
- SGU - 222 Little Rooks
- leetcode Remove Duplicates from Sorted Lists
- leetcode remove duplicates from sorted array
- 网络编程(1)--利用socket进行客户端与服务器端的通信
- 栋栋晓10:Javascript学习总结:基础知识2(语句,函数,)
- HDU - 2816 I Love You Too(水)
- 【Android基础篇】AlertDialog自定义setView方法的控件响应方法
- POJ2406 KMP next数组妙用
- HDU 1787 GCD Again 【欧拉函数模板】
- 【iOS开发】深入MVC---UITableView的数据源方法封装
- 百度地图、ECharts整合HT for Web网络拓扑图应用
- poj 2923
- Sorting - heap sort
- 有点迷茫