hdu杭电 2816 I Love You Too
2015-07-26 21:08
281 查看
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
Sample Output
//按照题目要求,一步一步模拟,最后输出答案
//做了非常久啊!
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
//按照题目要求,一步一步模拟,最后输出答案
//做了非常久啊!
<pre name="code" class="cpp">#include<stdio.h> #include<string.h> int i,len,j; char s1[1010],s2[1010]; char s[11][5]={"_","ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"}; char str[]={"QWERTYUIOPASDFGHJKLZXCVBNM"}; char s3[1010],s4[1010]; char res[1010]; int main() { while(gets(s1)) { len=strlen(s1); for(i=0,j=0;i<len;i+=2)//数字转换为字母 { s2[j++]=s[s1[i]-'0'-1][s1[i+1]-'0'-1]; } int k; for(i=0;i<j;++i)//按照题目给的方式进行字符变化 { for(k=0;k<26;++k) if(str[k]==s2[i]) { s1[i]='A'+k;break; } } len=len/2+1; for(i=0;i<len/2;++i)//把一个字符串分成两 { s3[i]=s1[i]; } s3[i]='\0'; int t=i; for(j=0;i<len-1;++i) { s4[j++]=s1[i]; } s4[j]='\0'; int l1=strlen(s3),l2=strlen(s4); int flag=1; i=0,j=0; char ch; while(s4[i]!='\0')//轮流存到res数组里 { if(!flag) { flag=1; ch=s4[i]; ++i; //if(s4[i]=='\0') continue; } else { flag=0; ch=s3[i]; } res[j++]=ch; } if(l1!=l2) res[j++]=s3[i]; /* k=0; for(i=0;i<j;++i,k+=2) { res[k]=s3[i]; res[k+1]=s4[i]; } for(;i<t;++i) { res[k]=s3[i]; ++k; } */ for(i=j-1;i>=0;--i) { printf("%c",res[i]); } puts(""); } return 0; }
相关文章推荐
- noi 滚cu后7月oi生活
- jquery表单验证插件
- 机器学习的最佳入门学习资源
- 打脸好爽,成功再看拒过你的投资人
- HTTP协议结构
- ACM 贪心 STL multiset 二分查找 hdu4268
- poj 3281 Dining(最大流)
- ZOJ - 2659 Box(差一点了,待ac)
- [CTCI] 下一个较大元素
- 爬虫框架汇总
- 欢迎使用CSDN-markdown编辑器
- java实现冒泡排序
- lab104_2
- 三种方法可以对swap 分区进行扩展
- linux中的ldd命令简介
- uiwebview通过cookie自动登录
- JSP九大内置对象
- tcpdump的使用
- 基本组成
- Const,Const函数,Const变量,函数后面的Const