poj2538

简单题

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
using namespace std;

char key[4][20];

int main()
{
//freopen("t.txt", "r", stdin);
strcpy(key[0], "1234567890-=");
strcpy(key[
1], "QWERTYUIOP[]\\");
strcpy(key[
2], "ASDFGHJKL;'");
strcpy(key[
3], "ZXCVBNM,./");
char st[1000];
while (gets(st) && strcmp(st, "") != 0)
{
int len = strlen(st);
for (int i = 0; i < len; i++)
{
if (st[i] == ' ')
{
putchar(
' ');
continue;
}
bool found = false;
for (int j = 0; j < 4; j++)
{
int len1 = strlen(key[j]);
for (int k = 0; k < len1; k++)
if (key[j][k] == st[i])
{
putchar(key[j][k
- 1]);
found
= true;
break;
}
if (found)
break;
}
}
putchar(
'\n');
}
return 0;
}

posted @ 2011-05-18 19:29  金海峰  阅读(206)  评论(0编辑  收藏  举报