Problem : 2816 ( I Love You Too ) Judge Status : Accepted
RunId : 5794868 Language : C++ Author : ssun
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
char st[12][6] = {"ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"};
string change1 = "QWERTYUIOPASDFGHJKLZXCVBNM";
string change2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main()
{
string str;
char mob[1000];
string mob1;
string mob2;
int i,j,k;
int a,b;
while(cin>>str)
{
for(i=0,j=0; i<str.size(); i=i+2,j++)
{
a = str[i]-'0';
b = str[i+1] - '0';
mob[j] = st[a-2][b-1];
for(k=0; k<change1.size(); k++)
if(mob[j]==change1[k])
{
mob[j] = change2[k];
break;
}
// cout<<mob[j];
// cout<<a<<" "<<b<<endl;
}
mob[j]='\0';
if(strlen(mob)%2==0)
{
mob1.assign(mob,0,(strlen(mob)/2));
mob2.assign(mob,strlen(mob)/2,strlen(mob)/2);
}
else
{
mob1.assign(mob,0,(strlen(mob)/2+1));
mob2.assign(mob,strlen(mob)/2+1,strlen(mob)/2);
}
// cout<<mob1<<endl<<mob2<<endl;
for(i=0; i<strlen(mob); i=i+2)
{
mob[i] = mob1[i/2];
mob[i+1] = mob2[i/2];
}
reverse(mob,mob+strlen(mob));
string final(mob);
cout<<final<<endl;
}
return 0;
}
HDU 2816 ( I Love You Too )
原创mb61c2e9efaa57a ©著作权
©著作权归作者所有:来自51CTO博客作者mb61c2e9efaa57a的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:关于<验证码>的实现和执行流程
下一篇:Struts2之异常处理
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
HDU 3033 I love sneakers!
题目链接:传送门题面:I love sneakers!Problem DescriptionAfte
动态规划 背包 HDU NOIP #include -
love you
love you
love you