zoukankan      html  css  js  c++  java
  • zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502

     The 12th Zhejiang Provincial Collegiate Programming Contest - J
    Convert QWERTY to Dvorak

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

    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;


    分析:

    直接打表模拟对照输出即可。

    AC代码:

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <stack>
     5 #include <queue>
     6 #include <map>
     7 #include <set>
     8 #include <vector>
     9 #include <math.h>
    10 #include <algorithm>
    11 using namespace std;
    12 #define ls 2*i
    13 #define rs 2*i+1
    14 #define up(i,x,y) for(i=x;i<=y;i++)
    15 #define down(i,x,y) for(i=x;i>=y;i--)
    16 #define mem(a,x) memset(a,x,sizeof(a))
    17 #define w(a) while(a)
    18 #define LL long long
    19 const double pi = acos(-1.0);
    20 #define Len 20005
    21 #define mod 19999997
    22 const int INF = 0x3f3f3f3f;
    23 
    24 char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:"zxcvbnm,./ZXCVBNM<>?"};
    25 char s2[]= {"[]{}',.pyfgcrl/="<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};
    26 char c;
    27 
    28 char print(char c)
    29 {
    30     for(int i=0; s1[i]; i++)
    31         if(s1[i]==c)
    32             return s2[i];
    33     return c;
    34 }
    35 int main()
    36 {
    37     w(~scanf("%c",&c))
    38     printf("%c",print(c));
    39 
    40     return 0;
    41 }
    View Code
  • 相关阅读:
    八皇后-递归
    代码复用3
    权限管理系统-角色组模块
    MzBlog分析
    linux shell 终端中文乱码(转)
    LINUX下中文语言包的安装(转)
    每一个程序员必须知道的业内英语词汇(转)
    80后创业故事之:兄弟散伙,创业失败(转)
    尊重用户的习惯审美,不要挑战用户的习惯(转)
    libpcre.so.1 cannot be found
  • 原文地址:https://www.cnblogs.com/jeff-wgc/p/4456556.html
Copyright © 2011-2022 走看看