zoukankan      html  css  js  c++  java
  • (字符串 键盘转换)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:

    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.

    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[100] = "_-+=qWwEeRrTtYyUuIiOoPp{[}]SsDdFfGgHhJjKkLl:;'ZzXxCcVvBbNnMm<,>.?/";
    char s2[100] = "{[}]'<,>.PpYyFfGgCcRrLl?/+=OoEeUuIiDdHhTtNnSs-:;QqJjKkXxBbMmWwVvZz";
    
    int main()
    {
        char s[N], ch='"';
    
        while(gets(s))
        {
            int i;
            for(i=0; s[i]; i++)
            {
                int flag=0, a;
                char ss[10];
    
                ss[0] = s[i];
                ss[1] = '';
    
                if(s[i]==ch)
                    printf("_"), flag = 1;
                else if(s[i]=='Q')
                    printf("%c", ch), flag = 1;
                else if(strstr(s1, ss))
                {
                    a = strstr(s1, ss) - s1;
                    printf("%c", s2[a]);
                    flag = 1;
                }
    
                if(flag==0) printf("%c", s[i]);
            }
    
            printf("
    ");
        }
        return 0;
    }
    勿忘初心
  • 相关阅读:
    mount挂载命令
    centos和redhat的区别
    查不认识字的方法
    Prometheus介绍及docker安装方式
    Pinpoint介绍及docker安装方式
    虚拟机安装linux
    yum命令
    docker命令
    PTA数据结构与算法题目集(中文) 7-43字符串关键字的散列映射 (25 分)
    PTA数据结构与算法题目集(中文) 7-42整型关键字的散列映射 (25 分)
  • 原文地址:https://www.cnblogs.com/YY56/p/4749664.html
Copyright © 2011-2022 走看看