Wertyu (GetChar () usage)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.