您的位置:首页 > 其它

zoj3878 Convert QWERTY to Dvorak(字符串)

2016-03-08 14:53 471 查看
这题让我一脸懵逼了好久,好久不做字符串都不会处理了,现在若是比赛我还真不一定能做出来= =。

刚开始不知道"字符串中表示前面要加\,编译一直通不过。。。

然后编译出来字符不对,原来是忘了加break,还以为表打错了看了好久。。。

最后发现连换行都忘了,真失败啊。。。

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string.h>
using namespace std;

const int N = 500;
const int INF = 1000000;

char a1[] = {"-=qwertyuiop[]asdfghjkl;'zxcvbnm,./_+QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?"};
char a2[] = {"[]',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz{}\"<>PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ"};

int main()
{
//   freopen("in.txt", "r", stdin);
char a;
int i;
while(~scanf("%c", &a))
{
if(a == '\n') printf("\n");
else
{
int len = strlen(a1);
for(i = 0; i < len; i ++)
{
if(a == a1[i])
{
a = a2[i];
break;
}
}
printf("%c", a);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  zoj