Keyword: search, ad hoc
Algorithm:
Well, you just have to set up a map and search the corresponding character.
That's it!
Notice how the map is built, though.
Code:
#include<cstdio>
#include<cctype>
#include<cstring>
int main()
{
char input, map[] = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
while( ( input = getchar() ) != EOF )
putchar( input != ' ' && input != '\n' ? *( strchr( map, tolower( input ) ) - 2 ) : input );
return 0;
}
沒有留言:
張貼留言