【題目敘述】https://zerojudge.tw/ShowProblem?problemid=c054
#include <iostream>
using namespace std;
char s[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
int main(){
string S;
int i, j;
while (getline(cin, S)){
for (i=0; i<S.length(); i++){
for (j=1; s[j] && s[j] != S[i]; j++);
if (s[j]) cout << s[j-1];
else cout << S[i];
}
cout << "\n";
}
}
Python code (credit: Amy Chou)
s = list("`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./")
while True:
try:
x = input()
for i in range(len(x)):
if x[i] in s[1:]:
print(s[s.index(x[i]) - 1], end="")
else:
print(x[i], end="")
print()
except:
break