hdu-2816 I Love You Too
来源:互联网 发布:c语言代码表白玫瑰花 编辑:程序博客网 时间:2024/05/16 15:49
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.
4194418141634192622374
41944181416341926223
ILOVEYOUTOO
VOYEUOOTIO
题意:给出一串长度不大于1000的数字,按每两个数字对应一个字母来解密(如图,即手机按键上的字母,如22代表B),解密后在根据解密对应的编码【3】来得到字母串,然后拆成两半(前部分不短于后部分),再按照【4】重新得到字母串,最后反序输出该字母串就ok啦。(貌似此密码很让人头疼呀。。。。别急,一步一步来,题目并不难)
#include<iostream>using namespace std;int main(){char a[1010];char b[505];char c[252];char d[252];char ans[505];char x[8][5]={"KXV","MCN","OPH","QRS","ZYI","JADL","EGW","BUFT"}; //已经按照密码定义了while(scanf("%s",a)!=EOF){int i,j,k;for(i=0,j=0;i<strlen(a);i+=2,j++){a[i]-='0'; //把字符转化为数字a[i+1]-='0';b[j]=x[a[i]-2][a[i+1]-1]; //求出每两个数字对应的一个字母}//要把字母串分成两个部分,而且前部分不短于后部分for(i=0;i<((strlen(a)/2)+1)/2;i++)c[i]=b[i];for(j=i,k=0;j<strlen(a)/2;j++,k++)d[k]=b[j];j=0;k=0;//再把两个字母串合并for(i=0;i<strlen(a)/2;i++){if((i+1)%2!=0)ans[i]=c[j++];elseans[i]=d[k++];}for(i=strlen(a)/2-1;i>=0;i--)printf("%c",ans[i]);printf("\n");}return 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
- 杭电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
- HDU 2816 I Love You Too [Ad Hoc]
- I Love You Too
- I Love You Too
- hd2816 I Love You Too
- hdoj 2816 I Love You Too 【模拟题】
- I Love You Too 2816 (字符串 好题)
- unity3d游戏物体跟着鼠标方向移动
- 从明天起,做一个做事有条有理的人
- 引用与指针区别C++
- misc fiction 科幻小说中的五大鸡肋发明
- 路由器设置
- hdu-2816 I Love You Too
- poj 2528 Mayor's posters
- C中的char[]与C++中的string
- ASP.ENT GridView隔行变色
- extern "c"的作用
- 数据库表、字段的命名规范
- shortcut的创建和删除
- MYSQL数据库字段命名及设计规范
- java 的 反射机制的使用列子