ZOJ 3878 Convert QWERTY to Dvorak

12 篇文章 0 订阅

题意:有一个键盘,CapLock键坏了,并且有些按键的位置装错了。已知正确的键盘与现在的键盘的按键的位置,求如果要输出正确的结果需要用怎么样的顺序按这个错位的键盘。输出这个按键的顺序

链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5526

思路:模拟,注意几个特殊字符的判断

注意点:无


以下为AC代码:

Run IDSubmit TimeJudge StatusProblem IDLanguageRun Time(ms)Run Memory(KB)User Name
39456832015-04-26 23:22:48Accepted 3878C++0x010040luminus
/* 
***********************************************
*# @Author  : Luminous11 (573728051@qq.com)
*# @Date    : 2015-04-26 22:59:08
*# @Link    : http://blog.csdn.net/luminous11
*********************************************** 
*/

#include <bits/stdc++.h>
#define clr(a, v) memset( a , v , sizeof(a) )
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1.0);
char str1[1005] = "~!@#$%^&*()_+WERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./";
char str2[1005] = "~!@#$%^&*(){}<>PYFGCRL?+|AOEUIDHTNS:QJKXBMWVZ`1234567890[]',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz";
char str[10000005];
int main()
{
	ios::sync_with_stdio ( false );
	while ( gets ( str ) ){
		int len = strlen ( str );
		int len1 = strlen ( str1 );
		for ( int i = 0; i < len; i ++ ){
			for ( int j = 0; j < len1; j ++ ){
				if ( str[i] == str1[j] ){
					printf ( "%c", str2[j] );
					goto X;
				}
			}
			if ( str[i] == 'Q' ){
				printf ( "\"" );
				goto X;
			}
			if ( str[i] == '//' ){
				printf ( "z" );
				goto X;
			}
			if ( str[i] == '\"'){
				printf ( "_" );
				goto X;
			}
			if ( str[i] == '\\' || str[i] == 'a' || str[i] == ' ' ){
				printf ( "%c", str[i] );
				goto X;
			}
			X:;
		}
		printf ( "\n" );
	}
    return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值