Convert QWERTY to Dvorak

来源:互联网 发布:虐心动画 知乎 编辑:程序博客网 时间:2024/06/18 11:07

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 brokenCaps Lock key. 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:

Qwerty LayoutThe QWERTY Layout
Dvorak LayoutThe 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.

<h4< dd="">
Output

The Dvorak document.

<h4< dd="">
Sample Input
Jgw Gqm Andpw a H.soav Patsfk f;doeNfk Gq.d slpt a X,dokt vdtnsaoheKjd yspps,glu pgld; aod yso kd;kgluZ1234567890`~!@#$%^&*()}"']_+-=ZQqWEwe{[\|ANIHDYf.,bt/ABCDEFuvwxyz
<h4< dd="">
Sample Output
Hi, I'm Abel, a Dvorak Layout user.But I've only a Qwerty keyboard.The following lines are for testing:1234567890`~!@#$%^&*()+_-={}[]:"'<>,.?/\|ABCDEFuvwxyzAXJE>Ugk,qf;
题意:题目给你一个字符串,要求看着给的标准的键盘转换为第二种图片那种样式输初对应键位的字母。
分析:定义两个数组,一个存第一个键盘的字母。另一个对应位置也存上位置。
需要注意的点:提交的时候可能会出现段落错误,这是因为你输入字符的那个数组开的不够大,导致出现了越界,这是个坑。
另外一个就是前面两个存键盘的数组,他需要一定的顺序,具体最后说,还有一个就是 认真看看图片,有些两个键盘没有发生变动的位置也需要存在里面。
#include <iostream>#include <cstdio>#include <algorithm>#include <string.h>#include <cmath>#include <math.h>using namespace std;int main(){//    char aa[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:"zxcvbnm,./ZXCVBNM<>?"};//    char aa[]= {"-=qwertyuiop[]asdfghjkl;'zxcvbnm,./_+QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?"};    char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"};    char s2[]= {"[]{}',.pyfgcrl/=\"<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};    char a[100001];    while(gets(a))    {        int c=strlen(a);        for(int i=0; i<c; i++)        {            for(int j=0; s1[j]!='\0'; j++)            {                if(a[i]==s1[j])                {                    a[i]=s2[j];                    break;                }            }        }        for(int i=0; i<c; i++)            printf("%c",a[i]);        printf("\n");    }}

看到我注释的了吗!这是我的自己写的,放到编译器里面,编译不通过,到现在还不知道咋回事
原创粉丝点击