zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    开发周记
    开发日记03
    开发日记01
    MVC实例应用
    MVC概述
    23种设计模式简述
    xx系统属性分析
    淘宝网质量属性
    架构漫谈阅读笔记
    浅谈软件架构师工作流程
  • 原文地址:https://www.cnblogs.com/zct994861943/p/6797387.html
Copyright © 2011-2022 走看看