题意
- 键盘被移位了,要求返回给出的字符在键盘上的左边的字符,空格正常。
思路
把键盘上的字符按从上到下从左到右顺序存进数组
每次读入字符判断他在数组中的位置,输出他前面一位的字符
换行和空格不变
代码
#include<cstdio>
using namespace std;
char type[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
int main(){
char c;
int i;
while(scanf("%c", &c)!=EOF){
if(c=='\n' || c==' ')
printf("%c", c);
else{
i = 0;
while(c!=type[i])
i++;
printf("%c", type[i-1]);
}
}
return 0;
}