(字符串 键盘转换)Convert QWERTY to Dvorak -- zoj -- 5526
链接:
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的更多相关文章
- 模拟 ZOJ 3878 Convert QWERTY to Dvorak
题目传送门 /* 模拟:手敲map一一映射,累! 除了忘记读入字符串不能用gets用getline外还是很顺利的AC了:) */ #include <cstdio> #include &l ...
- zoj 3878 Convert QWERTY to Dvorak【好坑的模拟】
Convert QWERTY to Dvorak Time Limit: 2 Seconds Memory Limit: 65536 KB Edward, a poor copy typis ...
- 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 ...
- Convert QWERTY to Dvorak
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- 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 ...
- ZOJ Problem Set - 3878 Convert QWERTY to Dvorak
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3878 /* 问题 很有意思的一道题目,纯模拟,注意细节和最后一 ...
- linux bash shell:最方便的字符串大小写转换(lowercase/uppercase conversion) (转)
原文地址:https://blog.csdn.net/10km/article/details/83384145 关于字符串大小写转换,是写 linux 脚本经常干的事儿,所以总想找个方便的方法让我少 ...
- JAVA将数字字符串强制转换成整型变量----求参数之和实验代码(附流程图)
一.设计思想 先将参数个数输出,并利用循环结果将参数逐个输出,再将字符串强制转化成整型,利用循环结构相加求和 二.程序流程图 三.源程序代码 package demo; public class Co ...
- Java中不同转换符实现不同数据类型到字符串的转换
String类的format()方法用于创建格式化的字符串以及连接多个字符串对象.熟悉C语言的同学应该记得C语言的sprintf()方法,两者有类似之处.format()方法有两种重载形式. form ...
随机推荐
- myeclipse越来越卡了怎么回事啊?
去掉拼写检查:windows->preferences->General->Editors->Text Editors->Spelling 将“Enable spell ...
- Androoid studio 2.3 AAPT err(Facade for 596378712): \\?\C:\Users\中文文件夹\.android\build-cache
错误如下: Error:Some file crunching failed, see logs for details Error:Execution failed for task ':app:m ...
- C#使用OpcNetApi.dll和OpcNetApi.Com.dll操作OPC
本人学习了一下.Net,恰好,51自学网,又要用这个.而网上很多VC6,VB6,VB .Net的但,很少C#的.现在研究一下,给出例子: 测试平台,是VS2008,KEPServer,OpcNetAp ...
- debian8下pgsql的主备同步热切手动脚本
9以后,通过流复制直接做 主:192.168.1.111 从:192.168.1.222 需要在postgres帐号下先配置ssh互信,双机都配置 sh-keygen -t rsa ssh-copy- ...
- [转][ASP.NET]ASP.NET 预编译网站
[转自]https://msdn.microsoft.com/zh-cn/library/ms227430(v=vs.80).aspx C:\Windows\Microsoft.NET\Framewo ...
- mysql-11元数据
我的mysql是用docker配置的,服务器状态和服务器配置变量都未设置,报错正常.
- Educational Codeforces Round 37-G.List Of Integers题解
一.题目 二.题目链接 http://codeforces.com/contest/920/problem/G 三.题意 给定一个$t$,表示有t次查询.每次查询给定一个$x$, $p$, $k$,需 ...
- Wasserstein距离 和 Lipschitz连续
EMD(earth mover distance)距离: 在计算机科学与技术中,地球移动距离(EMD)是一种在D区域两个概率分布距离的度量,就是被熟知的Wasserstein度量标准.不正式的说,如果 ...
- 关于memcache分布式一致性hash
consistent hashing 算法早在 1997 年就在论文 Consistent hashing and random trees 中被提出,目前在 cache 系统中应用越来越广泛: 1 ...
- 使用phpexcel导出到xls文件的时候出现乱码解决
<?php include 'global.php'; $ids = $_GET['ids']; $sql = "select * from crm_cost_end where id ...