ZOJ 3878 Convert QWERTY to Dvorak

来源:互联网 发布:中国企业数据库 编辑:程序博客网 时间:2024/06/07 01:04

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

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

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

注意点:无


以下为AC代码:

Run IDSubmit TimeJudge StatusProblem IDLanguageRun Time(ms)Run Memory(KB)User Name39456832015-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
原创粉丝点击