Convert QWERTY to Dvorak

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 Layout
The QWERTY Layout

Dvorak 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.

<h4< dd="">
Output

The Dvorak document.

<h4< dd="">
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
<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
`~!@#$%^&*()+_-={}[]:"'<>,.?/\|
ABCDEFuvwxyz
AXJE>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");
    }

}


看到我注释的了吗!这是我的自己写的,放到编译器里面,编译不通过,到现在还不知道咋回事
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值