• ZOJ3878: Convert QWERTY to Dvorak(浙江省赛2015)


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

    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 <stdio.h>
    #include <string.h>
    #include <ctype.h>
    #define N 100005
    char c[N];
    
    int main()
    {
        int n, i, j, k, T;
        char a[]= {"_+-=wertyuiop[]\asdfghjkl;zxcvbnm,./WERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?"};
        char b[]= {"{}[],.pyfgcrl/=\aoeuidhtns;qjkxbmwvz<>PYFGCRL?+|AOEUIDHTNS:QJKXBMWVZ"};
        while(gets(c))
        {
            for(i=0; i<strlen(c); i++)
            {
                k=0;
                if(c[i]==39)
                {
                    printf("%c", 45);
                    k=1;
                }
                else if(c[i]==34)
                {
                    k=1;
                    printf("%c", 95);
                }
                else if(c[i]=='q')
                {
                    k=1;
                    printf("%c", 39);
                }
                else if(c[i]=='Q')
                {
                    k=1;
                    printf("%c", 34);
                }
                for(j=0; j<strlen(a); j++)
                {
                    if(c[i]==a[j])
                    {
                        printf("%c", b[j]);
                        k=1;
                        break;
                    }
                }
                if(k==0)
                {
                    printf("%c", c[i]);
                }
            }
            printf("\n");
        }
        return 0;
    }
  • 相关阅读:
    71)PHP,使用cookie的语法问题
    70)PHP,cookie的安全传输和HTTPonly
    69)PHP,cookie的有效域
    68)PHP,cookie的详细属性和有效期
    C#中的internal关键字
    C# 中如何将一个类文件(XX.CS)封装成.dll文件
    c# 委托和事件(总结篇)
    c#事件实例三
    c#事件实例二
    c#事件实例一
  • 原文地址:https://www.cnblogs.com/zct994861943/p/6797387.html
Copyright © 2020-2023  润新知