用一個陣列代表鍵盤按鍵:char keyboard[]="QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./",然後找出輸入字元的i值,再輸出keyboard[i-1]。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
using namespace std; | |
int main() | |
{ | |
// freopen("input.txt","rt",stdin); | |
char keyboard[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; | |
char line[1000]; | |
while (gets(line)){ | |
for (int i=0; line[i]; i++){ | |
if (line[i] == ' ') printf(" "); | |
else{ | |
int j = 0; | |
while (line[i] != keyboard[j+1]) j++; | |
printf("%c",keyboard[j]); | |
} | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
沒有留言:
張貼留言