题意:有一个键盘,CapLock键坏了,并且有些按键的位置装错了。已知正确的键盘与现在的键盘的按键的位置,求如果要输出正确的结果需要用怎么样的顺序按这个错位的键盘。输出这个按键的顺序
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5526
思路:模拟,注意几个特殊字符的判断
注意点:无
以下为AC代码:
Run ID | Submit Time | Judge Status | Problem ID | Language | Run Time(ms) | Run Memory(KB) | User Name |
3945683 | 2015-04-26 23:22:48 | Accepted | 3878 | C++0x | 0 | 10040 | luminus |
/*
***********************************************
*# @Author : Luminous11 (573728051@qq.com)
*# @Date : 2015-04-26 22:59:08
*# @Link : http://blog.youkuaiyun.com/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;
}