题目连接:http://acm.tju.edu.cn/toj/showp.php?pid=13681368.   WERTYU


Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 3158   Accepted Runs: 1346

A common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.

Input consists of several lines of text. Each line may 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 to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

Sample Input

O S, GOMR YPFSU/

Output for Sample Input

I AM FINE TODAY.

Source: Waterloo Local Contest Jan. 17, 2001

题解:一个水题却教会了我如何使用getchar(), 在所有的读入数据的时候都是在没打回车之前数据存在缓存中,回车后开始将缓存中的数据读入到程序中,所以这个题,可以一个一个获取每个字符,然后处理,然后输出

代码中还有个细节就是\是一个转移字符,而\\表示的是一个代表\的字符,它只占一个char的空间

 #include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std; int main()
{
char s[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./0";
int i , c;
while((c = getchar())!=EOF)
{
int i;
for( i = ;i < strlen(s) ;i++)
{
if(s[i]==c){ printf("%c",s[i-]); break ;}
}
if(i==strlen(s)) printf("%c", c);
}
return ;
}

WERTYU(getchar()用法)的更多相关文章

  1. getchar()用法

    getchar() .从缓冲区读走一个字符,相当于清除缓冲区 .前面的scanf()在读取输入时会在缓冲区中留下一个字符'\n'(输入完s[i]的值后按回车键所致),所以如果不在此加一个getchar ...

  2. getchar()用法 【转】

    1.从缓冲区读走一个字符,相当于清除缓冲区 2.前面的scanf()在读取输入时会在缓冲区中留下一个字符'\n'(输入完s[i]的值后按回车键所致),所以如果不在此加一个getchar()把这个回车符 ...

  3. cin,cin.get(),cin.getline(),gets(),getchar()函数的用法

    1.cin>> 用法a:最基本的流输入用法,接受一个数字或字符,自动跳过输入的空格. 用法b:接受一个字符串,但是遇到除开头外的空格则会终止输入. #include<iostream ...

  4. C++语言中cin cin.getline cin.get getline gets getchar 的用法实例

    #include <iostream> #include <string> using namespace std; //关于cin cin.getline cin.get g ...

  5. 转:c语言EOF是什么?(及getchar()和putchar用法)

    我学习C语言的时候,遇到的一个问题就是EOF. 它是end of file的缩写,表示"文字流"(stream)的结尾.这里的"文字流",可以是文件(file) ...

  6. C语言——常用标准输入输出函数 scanf(), printf(), gets(), puts(), getchar(), putchar(); 字符串拷贝函数 strcpy(), strncpy(), strchr(), strstr()函数用法特点

    1 首先介绍几个常用到的转义符 (1)     换行符“\n”, ASCII值为10: (2)     回车符“\r”, ASCII值为13: (3)     水平制表符“\t”, ASCII值为 9 ...

  7. getchar() getch() getche() gets() puts() scanf()的用法及区别

    getchar() putchar(ch) scanf()   头文件stdio.h getch() getche()   头文件conio.h gets() puts()    头文件stdio.h ...

  8. c语言中getchar的用法

    /************************************************************************* > File Name: getchar2. ...

  9. Linux C 字符函数 getchar()、putchar() 与 EOF 详解

    首先给出<The_C_Programming_Language>这本书中的例子: #include <stdio.h> int main() { int c; c = getc ...

随机推荐

  1. [array] leetcode - 53. Maximum Subarray - Easy

    leetcode - 53. Maximum Subarray - Easy descrition Find the contiguous subarray within an array (cont ...

  2. [WinForm]委托应用①——窗口之间方法/控件调用

    不传参数 第二窗口:public partial class Form2 : Form { /// <summary> /// 定义委托 /// </summary> publ ...

  3. Java中的集合概述

    Java中的集合类有两个重要的分支,分别是接口Collection(包括List,Set等)和接口Map. 由于HashSet的内部实现原理使用了HashMap,所以我们先来了解Map集合类. 1.H ...

  4. sort 命令详解

    sort  作用:将文本文件内容加以排序,sort可针对文本文件的内容,以行为单位来排序  参数: -b 忽略每行前面开始出的空格字符. -c 检查文件是否已经按照顺序排序. -d 排序时,处理英文字 ...

  5. webpack之loader实践

    初识前端模板概念的开发者,通常都使用过underscore的template方法,非常简单好用,支持赋值,条件判断,循环等,基本可以满足我们的需求. 在使用Webpack搭建开发环境的时候,如果要使用 ...

  6. 每天学一点Docker(2)

    容器runtime 容器runtime是容器真正运行的地方,runtime需要和操作系统kernel紧密结合,为容器提供运行环境. 比如说,java程序比作一个容器,JVM就是runtime.JVM为 ...

  7. Python的伪私有属性

    什么是伪私有属性? 在Python中,没有类似 private 之类的关键字来声明私有方法或属性. Python中要声明私有属性,需要在属性前加上双下划线(但是结尾处不能有双下划线),如:self._ ...

  8. IO流之字节流知识总结

    IO流分为字符流和字节流. 字节流;可以读取任何文件,电脑以字节的方式储存 字符流:用来读取字符. 下面是我总结的思维导图. 相关练习代码 public class Demo { @Test publ ...

  9. 【练习】Html

    要求: 用html相关知识实现以下网页 <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

  10. css边框内圆角

    一.使用两个元素实现 html <div class="parent"> <div class="inset-radius">时代峰峻胜 ...