模拟 ZOJ 3878 Convert QWERTY to Dvorak

题目传送门

 1 /*
 2     模拟:手敲map一一映射,累!
 3         除了忘记读入字符串不能用gets用getline外还是很顺利的AC了:)
 4 */
 5 #include <cstdio>
 6 #include <iostream>
 7 #include <algorithm>
 8 #include <cmath>
 9 #include <cstring>
10 #include <string>
11 #include <map>
12 #include <set>
13 #include <queue>
14 #include <vector>
15 using namespace std;
16
17 const int MAXN = 1e2 + 10;
18 const int INF = 0x3f3f3f3f;
19 map<char, char> m;
20 string s;
21
22 void solve(void)
23 {
24     m[‘~‘] = ‘~‘;   m[‘`‘] = ‘`‘;
25     m[‘!‘] = ‘!‘;   m[‘1‘] = ‘1‘;
26     m[‘@‘] = ‘@‘;   m[‘2‘] = ‘2‘;
27     m[‘#‘] = ‘#‘;   m[‘3‘] = ‘3‘;
28     m[‘$‘] = ‘$‘;   m[‘4‘] = ‘4‘;
29     m[‘%‘] = ‘%‘;   m[‘5‘] = ‘5‘;
30     m[‘^‘] = ‘^‘;   m[‘6‘] = ‘6‘;
31     m[‘&‘] = ‘&‘;   m[‘7‘] = ‘7‘;
32     m[‘*‘] = ‘*‘;   m[‘8‘] = ‘8‘;
33     m[‘(‘] = ‘(‘;   m[‘9‘] = ‘9‘;
34     m[‘)‘] = ‘)‘;   m[‘0‘] = ‘0‘;
35     m[‘_‘] = ‘{‘;   m[‘-‘] = ‘[‘;
36     m[‘+‘] = ‘}‘;   m[‘=‘] = ‘]‘;
37     m[‘Q‘] = ‘"‘;   m[‘q‘] = ‘\‘‘;
38     m[‘W‘] = ‘<‘;   m[‘w‘] = ‘,‘;
39     m[‘E‘] = ‘>‘;   m[‘e‘] = ‘.‘;
40     m[‘R‘] = ‘P‘;   m[‘r‘] = ‘p‘;
41     m[‘T‘] = ‘Y‘;   m[‘t‘] = ‘y‘;
42     m[‘Y‘] = ‘F‘;   m[‘y‘] = ‘f‘;
43     m[‘U‘] = ‘G‘;   m[‘u‘] = ‘g‘;
44     m[‘I‘] = ‘C‘;   m[‘i‘] = ‘c‘;
45     m[‘O‘] = ‘R‘;   m[‘o‘] = ‘r‘;
46     m[‘P‘] = ‘L‘;   m[‘p‘] = ‘l‘;
47     m[‘{‘] = ‘?‘;   m[‘[‘] = ‘/‘;
48     m[‘}‘] = ‘+‘;   m[‘]‘] = ‘=‘;
49     m[‘|‘] = ‘|‘;   m[‘\\‘] = ‘\\‘;
50     m[‘A‘] = ‘A‘;   m[‘a‘] = ‘a‘;
51     m[‘S‘] = ‘O‘;   m[‘s‘] = ‘o‘;
52     m[‘D‘] = ‘E‘;   m[‘d‘] = ‘e‘;
53     m[‘F‘] = ‘U‘;   m[‘f‘] = ‘u‘;
54     m[‘G‘] = ‘I‘;   m[‘g‘] = ‘i‘;
55     m[‘H‘] = ‘D‘;   m[‘h‘] = ‘d‘;
56     m[‘J‘] = ‘H‘;   m[‘j‘] = ‘h‘;
57     m[‘K‘] = ‘T‘;   m[‘k‘] = ‘t‘;
58     m[‘L‘] = ‘N‘;   m[‘l‘] = ‘n‘;
59     m[‘:‘] = ‘S‘;   m[‘;‘] = ‘s‘;
60     m[‘"‘] = ‘_‘;   m[‘\‘‘] = ‘-‘;
61     m[‘Z‘] = ‘:‘;   m[‘z‘] = ‘;‘;
62     m[‘X‘] = ‘Q‘;   m[‘x‘] = ‘q‘;
63     m[‘C‘] = ‘J‘;   m[‘c‘] = ‘j‘;
64     m[‘V‘] = ‘K‘;   m[‘v‘] = ‘k‘;
65     m[‘B‘] = ‘X‘;   m[‘b‘] = ‘x‘;
66     m[‘N‘] = ‘B‘;   m[‘n‘] = ‘b‘;
67     m[‘M‘] = ‘M‘;   m[‘m‘] = ‘m‘;
68     m[‘<‘] = ‘W‘;   m[‘,‘] = ‘w‘;
69     m[‘>‘] = ‘V‘;   m[‘.‘] = ‘v‘;
70     m[‘?‘] = ‘Z‘;   m[‘/‘] = ‘z‘;
71     m[‘ ‘] = ‘ ‘;
72 }
73
74 int main(void)      //ZOJ 3878 Convert QWERTY to Dvorak
75 {
76     //freopen ("J.in", "r", stdin);
77
78     solve ();
79     while (getline (cin, s))
80     {
81         for (int i=0; s[i]; ++i)
82             cout << m[s[i]];
83         cout << endl;
84     }
85
86     return 0;
87 }
88
89 /*
90 Hi, I‘m Abel, a Dvorak Layout user.
91 But I‘ve only a Qwerty keyboard.
92 The following lines are for testing:
93 1234567890
94 `[email protected]#$%^&*()+_-={}[]:"‘<>,.?/\|
95 ABCDEFuvwxyz
96 AXJE>Ugk,qf;
97 */

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 #include <stack>
 5 #include <queue>
 6 #include <map>
 7 #include <set>
 8 #include <vector>
 9 #include <math.h>
10 #include <algorithm>
11 using namespace std;
12 #define ls 2*i
13 #define rs 2*i+1
14 #define up(i,x,y) for(i=x;i<=y;i++)
15 #define down(i,x,y) for(i=x;i>=y;i--)
16 #define mem(a,x) memset(a,x,sizeof(a))
17 #define w(a) while(a)
18 #define LL long long
19 const double pi = acos(-1.0);
20 #define Len 20005
21 #define mod 19999997
22 const int INF = 0x3f3f3f3f;
23
24 char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;‘ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"};
25 char s2[]= {"[]{}‘,.pyfgcrl/=\"<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};
26 char c;
27
28 char print(char c)
29 {
30     for(int i=0; s1[i]; i++)
31         if(s1[i]==c)
32             return s2[i];
33     return c;
34 }
35 int main()
36 {
37     w(~scanf("%c",&c))
38     printf("%c",print(c));
39
40     return 0;
41 }

网上题解,两行,给跪了!

时间: 2024-10-24 20:48:59

模拟 ZOJ 3878 Convert QWERTY to Dvorak的相关文章

zoj 3878 Convert QWERTY to Dvorak【好坑的模拟】

Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB 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

OJ Problem Set - 3878 Convert QWERTY to Dvorak

题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3878 1 /* 2 问题 3 很有意思的一道题目,纯模拟,注意细节和最后一行的空格就行了 4 */ 5 6 #include<iostream> 7 #include<string> 8 #include<map> 9 using namespace std; 10 11 int main() 12 { 13 map<char,

12th浙江省省赛 J Convert QWERTY to Dvorak(细节模拟题)

Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, a poor copy typist, is a user of the Dvorak Layout.But now he has only a QWERTY Keyboard with a brokenCaps Lockkey, so Edward never presses the brokenCaps Lockkey.Luck

J - Convert QWERTY to Dvorak——ZOJ

J - Convert QWERTY to Dvorak Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit 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 Loc

ACM学习历程—ZOJ3878 Convert QWERTY to Dvorak(Hash &amp;&amp; 模拟)

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.

Convert QWERTY to Dvorak

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3878 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 E

ZOJ 3878-Convert QWERTY to Dvorak【模拟】

Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB 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

BFS+模拟 ZOJ 3865 Superbot

题目传送门 1 /* 2 BFS+模拟:dp[i][j][p] 表示走到i,j,方向为p的步数为多少: 3 BFS分4种情况入队,最后在终点4个方向寻找最小值:) 4 */ 5 #include <cstdio> 6 #include <iostream> 7 #include <algorithm> 8 #include <cstring> 9 #include <string> 10 #include <queue> 11 usi

[贪心+模拟] zoj 3829 Known Notation

题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5383 Known Notation Time Limit: 2 Seconds      Memory Limit: 65536 KB Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science.