链接:

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5526

Time Limit: 2 Seconds      Memory Limit: 65536 KB


Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a broken Caps Lock key, so Edward never presses the broken Caps Lockkey. Luckily, all the other keys on the QWERTY keyboard work well. Every day, he has a lot of documents to type. Thus he needs a converter to translate QWERTY into Dvorak. Can you help him?

The QWERTY Layout and the Dvorak Layout are in the following:

The QWERTY Layout

The Dvorak Layout

Input

A QWERTY document Edward typed. The document has no more than 100 kibibytes. And there are no invalid characters in the document.

Output

The Dvorak document.

Sample Input

Jgw Gqm Andpw a H.soav Patsfk f;doe
Nfk Gq.d slpt a X,dokt vdtnsaohe
Kjd yspps,glu pgld; aod yso kd;kgluZ
1234567890
`~!@#$%^&*()}"']_+-=ZQqWEwe{[\|
ANIHDYf.,bt/
ABCDEFuvwxyz

Sample Output

Hi, I'm Abel, a Dvorak Layout user.
But I've only a Qwerty keyboard.
The following lines are for testing:
1234567890
`~!@#$%^&*()+_-={}[]:"'<>,.?/\|
ABCDEFuvwxyz
AXJE>Ugk,qf;

代码:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h> #define N 100000 char s1[] = "_-+=qWwEeRrTtYyUuIiOoPp{[}]SsDdFfGgHhJjKkLl:;'ZzXxCcVvBbNnMm<,>.?/";
char s2[] = "{[}]'<,>.PpYyFfGgCcRrLl?/+=OoEeUuIiDdHhTtNnSs-:;QqJjKkXxBbMmWwVvZz"; int main()
{
char s[N], ch='"'; while(gets(s))
{
int i;
for(i=; s[i]; i++)
{
int flag=, a;
char ss[]; ss[] = s[i];
ss[] = '\0'; if(s[i]==ch)
printf("_"), flag = ;
else if(s[i]=='Q')
printf("%c", ch), flag = ;
else if(strstr(s1, ss))
{
a = strstr(s1, ss) - s1;
printf("%c", s2[a]);
flag = ;
} if(flag==) printf("%c", s[i]);
} printf("\n");
}
return ;
}

(字符串 键盘转换)Convert QWERTY to Dvorak -- zoj -- 5526的更多相关文章

  1. 模拟 ZOJ 3878 Convert QWERTY to Dvorak

    题目传送门 /* 模拟:手敲map一一映射,累! 除了忘记读入字符串不能用gets用getline外还是很顺利的AC了:) */ #include <cstdio> #include &l ...

  2. zoj 3878 Convert QWERTY to Dvorak【好坑的模拟】

    Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, a poor copy typis ...

  3. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  4. Convert QWERTY to Dvorak

      Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Pract ...

  5. ACM学习历程—ZOJ3878 Convert QWERTY to Dvorak(Hash && 模拟)

    Description Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY ...

  6. ZOJ Problem Set - 3878 Convert QWERTY to Dvorak

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3878 /* 问题 很有意思的一道题目,纯模拟,注意细节和最后一 ...

  7. linux bash shell:最方便的字符串大小写转换(lowercase/uppercase conversion) (转)

    原文地址:https://blog.csdn.net/10km/article/details/83384145 关于字符串大小写转换,是写 linux 脚本经常干的事儿,所以总想找个方便的方法让我少 ...

  8. JAVA将数字字符串强制转换成整型变量----求参数之和实验代码(附流程图)

    一.设计思想 先将参数个数输出,并利用循环结果将参数逐个输出,再将字符串强制转化成整型,利用循环结构相加求和 二.程序流程图 三.源程序代码 package demo; public class Co ...

  9. Java中不同转换符实现不同数据类型到字符串的转换

    String类的format()方法用于创建格式化的字符串以及连接多个字符串对象.熟悉C语言的同学应该记得C语言的sprintf()方法,两者有类似之处.format()方法有两种重载形式. form ...

随机推荐

  1. Kotlin Android学习入门

    1.基本语法 https://github.com/mcxiaoke/kotlin-notes/blob/master/kotlin-tutorial-basic.md 2.推荐两篇Kotlin An ...

  2. Android Studio使用JDBC远程连接mysql的注意事项(附示例)

    JDBC为java程序访问各种类型的关系型数据库提供了统一的接口,用户不必针对不同数据库写出不同的代码,但是使用JDBC必须得下载相应的驱动,比如我这里是要连接mysql,于是就到mysql官网去下载 ...

  3. Java获取Resource目录下的文件

    工程结构: 有两种方式: Java代码中的类,要获取Resource资源文件目录下文件 绝对路径寻址 String s1 = this.getClass().getResource("/te ...

  4. c端用户体系实现方案

    问题: 同个用户的来源 有微信,脸书,浏览器 怎么鉴定他们为同一个人呢? 解决: 数据库2张表 c_user表 记录c端用户 信息 记录 唯一uuid ,平台来源 手机号码 浏览器进来是匿名用户 无手 ...

  5. 这个移动通讯中 DB 、DBm 、瓦的基本知识的问题:

    1.对于无线工程师来说更常用分贝dBm这个单位,dBm单位表示相对于1毫瓦的分贝数,dBm和W之间的关系是:dBm=10*lg(mW)1w的功率,换算成dBm就是10×lg1000=30dBm.2w是 ...

  6. C++ - memset的效率和源码分析

      void *memset(void *s, int ch, size_t n); 作用:将s所指向的某一块内存中的每个字节的内容全部设置为ch指定的ASCII值, 块的大小由第三个参数指定,这个函 ...

  7. Mysql总结(一)

    数据库命令:创建create database 数据库名 charset=utf8;删除drop database 数据库名;查看所有数据库:show databases;使用数据库:use 数据库名 ...

  8. HTTP 协议基础

    HTTP 协议的主要特点可概括如下: 1.支持客户/服务器模式. 2.简单快速:客户向服务器请求服务时,只需传送请求方法和路径.请求方法常用的有GET.HEAD.POST.每种方法规定了客户与服务器联 ...

  9. ubuntu上安装 MySQL 启动/停止 连接MySQL

    1.Ubuntu上安装MySQL服务   1.安装服务端   sudo apt-get install mysql-server    2.安装客户端   sudo apt-get install m ...

  10. Java Reference & ReferenceQueue一览

    Overview The java.lang.ref package provides more flexible types of references than are otherwise ava ...