C++ 11 代码如下:
1 #include<iostream> 2 using namespace std; 3 const char s[] = { "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;‘ZXCVBNM,./" }; //注意转义字符 4 int main() { 5 int c, i; 6 while ((c = getchar()) != EOF) { 7 for (i = 1; s[i] && s[i] != c; i++); 8 if (s[i]) putchar(s[i - 1]); 9 else putchar(c); 10 } 11 return 0; 12 }
原文:https://www.cnblogs.com/pgzhang/p/9221835.html