样例:
输入:O S, GOMR YPFSU/
输出:I AM FINE TODAY.
1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 char s[] = "`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./"; 6 int i, c; 7 while ((c = getchar()) != EOF) 8 { 9 //cout << c << endl << endl; 10 for (i = 1; s[i] && s[i] != c; i++); 11 //cout << endl << endl; 12 if (s[i]) putchar(s[i - 1]); 13 else putchar(c); 14 } 15 return 0; 16 }
知识点:代码很短,不过很有价值,char数组的灵活处理,char可以与int进行比较;