UVa 10082 WERTYU
解題策略
慶祝新書入手,解了書中第一題噴題。盯著鍵盤建好Ascii對應表:如 map['W'] = 'Q',注意空格跟換行不需要換字。
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
/** | |
* UVa 10082 WERTYU | |
* Author: chchwy | |
* Last Modified: 2010.04.21 | |
*/ | |
#include<cstdio> | |
int main() | |
{ | |
char key[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; | |
//set mapping | |
char map[256]; | |
for (int i = 0; key[i] != NULL; ++i) | |
map[ key[i] ] = key[i - 1]; | |
map[' '] = ' '; | |
map['\n'] = '\n'; | |
//run | |
int c; | |
while ((c = getchar()) != EOF) | |
putchar(map[c]); | |
return 0; | |
} |
留言
張貼留言