ZOJ 3878 Convert QWERTY to Dvorak(暴力)

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 brokenCaps Lockkey, so Edward never presses the brokenCaps 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;

Author: ZHOU, Yuchen

Source: The 12th Zhejiang Provincial Collegiate Programming Contest

题目意思就是键盘从上面那个原来的换成下面这个现在的,输出新的字符串。

/* 
* Copyright (c) 2016, 烟台大学计算机与控制工程学院 
* All rights reserved. 
* 文件名称:zoj.cpp 
* 作    者:单昕昕 
* 完成日期:2016年4月2日 
* 版 本 号:v1.0 
*/  
#include <iostream>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
char s[100000];//这个数组要开大!不然会错!题目里说的是100KB呀喂!不是100阿!
void f(char c)//每种情况枚举
{
    if(c=='Q') cout<<"\"";
    else if(c=='q') cout<<"'";
    else if(c=='W') cout<<"<";
    else if(c=='w') cout<<",";
    else if(c=='E') cout<<">";
    else if(c=='e') cout<<".";
    else if(c=='R') cout<<"P";
    else if(c=='r') cout<<"p";
    else if(c=='T') cout<<"Y";
    else if(c=='t') cout<<"y";
    else if(c=='Y') cout<<"F";
    else if(c=='y') cout<<"f";
    else if(c=='U') cout<<"G";
    else if(c=='u') cout<<"g";
    else if(c=='I') cout<<"C";
    else if(c=='i') cout<<"c";
    else if(c=='O') cout<<"R";
    else if(c=='o') cout<<"r";
    else if(c=='P') cout<<"L";
    else if(c=='p') cout<<"l";
    else if(c=='{') cout<<"?";
    else if(c=='[') cout<<"/";
    else if(c=='}') cout<<"+";
    else if(c==']') cout<<"=";
    else if(c=='-') cout<<"[";
    else if(c=='_') cout<<"{";
    else if(c=='=') cout<<"]";
    else if(c=='+') cout<<"}";
    else if(c=='S') cout<<"O";
    else if(c=='s') cout<<"o";
    else if(c=='D') cout<<"E";
    else if(c=='d') cout<<"e";
    else if(c=='F') cout<<"U";
    else if(c=='f') cout<<"u";
    else if(c=='G') cout<<"I";
    else if(c=='g') cout<<"i";
    else if(c=='H') cout<<"D";
    else if(c=='h') cout<<"d";
    else if(c=='J') cout<<"H";
    else if(c=='j') cout<<"h";
    else if(c=='K') cout<<"T";
    else if(c=='k') cout<<"t";
    else if(c=='L') cout<<"N";
    else if(c=='l') cout<<"n";
    else if(c==':') cout<<"S";
    else if(c==';') cout<<"s";
    else if(c=='S') cout<<"O";
    else if(c=='s') cout<<"o";
    else if(c=='\'') cout<<"-";//格式符要多加一个“\”
    else if(c=='"') cout<<"_";
    else if(c=='Z') cout<<":";
    else if(c=='z') cout<<";";
    else if(c=='X') cout<<"Q";
    else if(c=='x') cout<<"q";
    else if(c=='C') cout<<"J";
    else if(c=='c') cout<<"j";
    else if(c=='V') cout<<"K";
    else if(c=='v') cout<<"k";
    else if(c=='B') cout<<"X";
    else if(c=='b') cout<<"x";
    else if(c=='N') cout<<"B";
    else if(c=='n') cout<<"b";
    else if(c=='<') cout<<"W";
    else if(c==',') cout<<"w";
    else if(c=='>') cout<<"V";
    else if(c=='.') cout<<"v";
    else if(c=='?') cout<<"Z";
    else if(c=='/') cout<<"z";
    else cout<<c;
}
int main()
{

    int i;
    while(gets(s))//不能cin,因为有空格
    {
        for(i=0; s[i]!='\0'; ++i)
            f(s[i]);
        cout<<endl;
    }
    return 0;
}

哎,坑爹的100KB,开小了就报这个错:

手打每种情况也不容易呀喂~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值