http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19338
首先读入的整个字符串,是向右偏移了一位形成的,要我们输出原来的字符串,这样可以用一个字符数组把键盘上所有能打印出的字符保存下来,然后每次读入一个字符后判断在字符数组中的下标输出前一位即可,注意空格输出空格。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define ll long long
#define inf 0x7f7f7f7f
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)
#define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define Read() freopen("din.txt", "r", stdin)
#define Write() freopen("dout.txt", "w", stdout);
#define Nn 510007
#define Mc 26
using namespace std;
char s[55]="`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./";
int main()
{
int i,c;
while((c=getchar())!=EOF)
{
for(i=1;s[i]&&s[i]!=c;i++);
if(s[i]) putchar(s[i-1]); //s[i]!='\0' '\0'的值是0;
else putchar(c);
}
return 0;
}