ZOJ 3878 Convert QWERTY to Dvorak

題意:有一個鍵盤,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 ([email protected])
*# @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;
}


發佈了228 篇原創文章 · 獲贊 5 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章