ZOJ - 3878 Convert QWERTY to Dvorak (暴力)水&坑

27 篇文章 0 订阅
ZOJ - 3878
Time Limit:                                                        2000MS                        Memory Limit: 65536KB 64bit IO Format:                            %lld & %llu                       

Status

Description

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

<h4< body="">

Input

A QWERTY document Edward typed. The document has no more than 100 kibibytes. And there are no invalid characters in the document.

<h4< body="">

Output

The Dvorak document.

<h4< body="">

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< body="">

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;

Hint

Source

The 12th Zhejiang Provincial Collegiate Programming Contest
//题意:
小明的键盘和我们正常的键盘不同,如上图对应的情况,现在说输入一个字符串,让你输出小明的键盘输出的字符串。
//思路:
水题,直接模拟,但是很坑,题中要求的是输入不超过100K(1K=1024个字符),这块没看清,以为是100个字符,所以就WA了一遍。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
char s[10000010];
char c[10000010];
int main()
{
	while(gets(s)!=NULL)
	{
		memset(c,'\0',sizeof(c));
		int len=strlen(s);
		for(int i=0;i<len;i++)
		{
			if(s[i]=='_') c[i]='{';
			else if(s[i]=='-') c[i]='[';
			else if(s[i]=='+') c[i]='}';
			else if(s[i]=='=') c[i]=']';
			else if(s[i]=='Q') c[i]='"';
			else if(s[i]=='q') c[i]=39;
			else if(s[i]=='W') c[i]='<';
			else if(s[i]=='w') c[i]=',';
			else if(s[i]=='E') c[i]='>';
			else if(s[i]=='e') c[i]='.';
			else if(s[i]=='R') c[i]='P';
			else if(s[i]=='r') c[i]='p';
			else if(s[i]=='T') c[i]='Y';
			else if(s[i]=='t') c[i]='y';
			else if(s[i]=='Y') c[i]='F';
			else if(s[i]=='y') c[i]='f';
			else if(s[i]=='U') c[i]='G';
			else if(s[i]=='u') c[i]='g';
			else if(s[i]=='I') c[i]='C';
			else if(s[i]=='i') c[i]='c';
			else if(s[i]=='O') c[i]='R';
			else if(s[i]=='o') c[i]='r';
			else if(s[i]=='P') c[i]='L';
			else if(s[i]=='p') c[i]='l';
			else if(s[i]=='{') c[i]='?';
			else if(s[i]=='[') c[i]='/';
			else if(s[i]=='}') c[i]='+';
			else if(s[i]==']') c[i]='=';
			else if(s[i]=='S') c[i]='O';
			else if(s[i]=='s') c[i]='o';
			else if(s[i]=='D') c[i]='E';
			else if(s[i]=='d') c[i]='e';
			else if(s[i]=='F') c[i]='U';
			else if(s[i]=='f') c[i]='u';
			else if(s[i]=='G') c[i]='I';
			else if(s[i]=='g') c[i]='i';
			else if(s[i]=='H') c[i]='D';
			else if(s[i]=='h') c[i]='d';
			else if(s[i]=='J') c[i]='H';
			else if(s[i]=='j') c[i]='h';
			else if(s[i]=='K') c[i]='T';
			else if(s[i]=='k') c[i]='t';
			else if(s[i]=='L') c[i]='N';
			else if(s[i]=='l') c[i]='n';
			else if(s[i]==':') c[i]='S';
			else if(s[i]==';') c[i]='s';
			else if(s[i]=='"') c[i]='_';
			else if(s[i]==39) c[i]='-';
			else if(s[i]=='Z') c[i]=':';
			else if(s[i]=='z') c[i]=';';
			else if(s[i]=='X') c[i]='Q';
			else if(s[i]=='x') c[i]='q';
			else if(s[i]=='C') c[i]='J';
			else if(s[i]=='c') c[i]='j';
			else if(s[i]=='V') c[i]='K';
			else if(s[i]=='v') c[i]='k';
			else if(s[i]=='B') c[i]='X';
			else if(s[i]=='b') c[i]='x';
			else if(s[i]=='N') c[i]='B';
			else if(s[i]=='n') c[i]='b';
			else if(s[i]=='<') c[i]='W';
			else if(s[i]==',') c[i]='w';
			else if(s[i]=='>') c[i]='V';
			else if(s[i]=='.') c[i]='v';
			else if(s[i]=='?') c[i]='Z';
			else if(s[i]=='/') c[i]='z';
			else c[i]=s[i];
		}
		puts(c);
	}
	return 0;
}

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值