http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=110301&format=html

UVA 10082 WERTYU(键盘)

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=31&page=show_problem&problem=1023

题目大意:

一种打错字的方式是把手放在了正确位置的右边一格,将‘Q’打成‘W’,将‘J’打成‘K’等。

根据输入的字符串,输出正确的字符串,输入的每组测试数据可能包括数字、空格、大写字母(除了‘Q’,‘A’,‘Z’)或者是图片上的标点符号,除了后引号‘’’,键名为单词的(Tab、BackSp、Control等)不会出现在输入中。

样例输入:

O S, GOMR YPFSU/
样例输出:
I AM FINE TODAY.
#include<iostream>
#include<string>
using namespace std;

int main()
{
string kb="; M0,.9012345678 L - AVXSWDFGUHJKNBIOQEARYCQZTZP][";
string str;
int i,len;
while(getline(cin,str))
{
len=str.length();
for(i=0;i<len;i++)
{
if(str[i]==' ')
cout<<' ';
else
cout<<kb[str[i]-39];
}
cout<<endl;
}
return 0;
}
#include<iostream>
#include<string>
using namespace std;

int main()
{
string kb="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
string str;
int i,len;
while(getline(cin,str))
{
len=str.length();
for(i=0;i<len;i++)
{
if(str[i]==' ')
cout<<' ';
else
cout<<kb[kb.find_first_of(str[i])-1];
}
cout<<endl;
}
return 0;
}


posted on 2012-03-07 18:03  pcoda  阅读(280)  评论(0编辑  收藏  举报