[UVA][字串理] 11278 - One-Handed Typist@Morris' Blog|PChome Online 人新台
2013-02-14 17:21:47| 人2,077| 回0 | 上一篇 | 下一篇

[UVA][字串理] 11278 - One-Handed Typist

0 收藏 0 0 站台

Problem A

ONE-HANDED TYPIST

Recently, a programming contest coach had a terrible accident and broke his left arm. It was then that he discovered how dificult it was to type with only one hand. He really needed to find a way to increase his typing speed, since he had to create problems in a hurry for an upcoming programming contest.

His solution was to switch from the standard QWERTY keyboard layout to a right-handed Dvorak keyboard layout (see diagrams below). It is pretty easy on a modern machine to change the keyboard layout in software, so that striking a key on the standard keyboard would give you the character at that position on the desired layout, whether or not it matches the physically labeled character.

The standard QWERTY keyboard layout, shift-modified on right.

The right-handed Dvorak keyboard layout, shift-modified on right.

One day, as the coach was typing out a problem statement with his right hand, he discovered that he had forgotten to change the keyboard layout from QWERTY to Dvorak on the machine! Naturally, all the text came out scrambled, because he had struck the keys as if it were a right-handed Dvorak keyboard. Alas, it would take too much time to retype all the text with only one hand.

Can you write a program to help the coach salvage his text?

Input

The input file consists of several lines of text, representing the text typed by the coach on a QWERTY keyboard layout when he thought he was using a right-handed Dvorak layout. Each line contains no more than 1000 alphanumeric characters, spaces, and punctuation found on the keyboard.

Output

For each line in the input, your program should write the line of text that the coach had meant to type. In other words, output the text as if it had been keyed using a right-handed Dvorak layout.

Sample Input

Hg66t Mty6k! Jhg 4ibl; pytmn 8tc 5i79urrr t,gy jhg 6fxo kt.r 

Output for the Sample Input

Hello World! The quick brown fox jumps... over the lazy dog. 

Sonny Chan
Calgary Collegiate Programming Contest 2006

#include <stdio.h>

int main() {
    char QWERTY[] = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
    char DVOARK[] = "123qjlmfp/[]456.orsuyb;=\\789aehtdck-0zx,inwvg'";
    char M1[] = "!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?";
    char M2[] = "!@#QJLMFP?{}$%^>ORSUYB:+|&*(AEHTDCK_)ZX<INWVG\"";
  &bsp; char cmd[1024];
    int i, j;
    while(gets(cmd)) {
        for(i = 0; cmd[i]; i++) {
            int flag = 0;
            for(j = 0; QWERTY[j]; j++)
                if(QWERTY[j] == cmd[i])
                    putchar(DVOARK[j]), flag = 1;
            for(j = 0; M1[j]; j++)
                if(M1[j] == cmd[i])
                    putchar(M2[j]), flag = 1;
            if(!flag)   putchar(cmd[i]);
        }
        puts("");
    }
    return 0;
}

台: Morris
人(2,077) | 回(0)| 推 (0)| 收藏 (0)|
全站分: 不分 | 人分: UVA |
此分下一篇:[UVA][stack] 11111 - Generalized Matrioshkas
此分上一篇:[UVA][BWT逆] 741 - Burrows Wheeler Decoder

是 (若未登入"人新台"看不到回覆唷!)
* 入:
入片中算式的果(可能0) 
(有*必填)
TOP
全文
ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86