Topic Connection: http://acm.tju.edu.cn/toj/showp.php?pid=1368 1368. Wertyu Time limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 3158 Accepted Runs: 1346
A Common typing the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" are typed as "K" and so on. You is to decode a message typed in this manner.
Input consists of several lines of text. 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.] is not represented in the input. You is to replace each letter or punctuation symbol by the one of the immediately to it 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.
Source: Waterloo Local Contest Jan, 2001
Problem: A water question but taught me how to use GetChar (), when all the data is read in the data in the cache before the return, enter the cache after the start of the data read into the program, so the problem, can be a one to get each character, then processing, and then output
Another detail in the code is that \ is a transfer character, and \ \ represents a character representing \, which occupies only one char space
1#include <iostream>2#include <cstdio>3#include <string>4#include <cstring>5#include <algorithm>6 using namespacestd;7 8 intMain ()9 {Ten Chars[ the] ="' 1234567890-=qwertyuiop[]\\asdfghjkl; ' zxcvbnm,./0"; One intI, C; A while((c = GetChar ())! =EOF) - { - inti; the for(i =0; i < strlen (s); i++) - { - if(S[I]==C) {printf ("%c", s[i-1]); Break ;} - } + if(I==strlen (s)) printf ("%c", c); - } + return 0; A}
Wertyu (GetChar () usage)