10082-wertyu
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1023
A Common typing the hands on the keyboard one row to the right of the correct position. So "Q" are typed as "W" and "J" is typed as "K" and ".". You are are to decode a message typed into this manner.
Input consists of several lines of text. Each line could contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except Back-quote ( `)]. Keys labelled with words [Tab, Backsp, control,etc..] are not represented in the input. You are are to replace the "one" or "punction" by the "one immediately to" left on the QWERTY keyboard shown above. Spaces in the input should is echoed in the output.
Sample Input
O S, Gomr ypfsu/
Output for Sample Input
I AM FINE today.
Complete code:
/*0.013s*/
#include <cstdio>
const char s[] = "' 1234567890-=qwertyuiop[]\\asdfghjkl; ' Zxcvbnm,./";
int main (void)
{
char C;
int i;
while (~ (c = GetChar ()))
{for
(i = 1; s[i] && s[i]!= C; i++)
;
Putchar (S[i]? S[i-1]: c);
}
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/