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,char> mp;
 14     mp[‘`‘]=‘`‘;
 15     mp[‘~‘]=‘~‘;
 16
 17     mp[‘1‘]=‘1‘;
 18     mp[‘!‘]=‘!‘;
 19
 20     mp[‘@‘]=‘@‘;
 21     mp[‘2‘]=‘2‘;
 22
 23     mp[‘#‘]=‘#‘;
 24     mp[‘3‘]=‘3‘;
 25
 26     mp[‘$‘]=‘$‘;
 27     mp[‘4‘]=‘4‘;
 28
 29     mp[‘%‘]=‘%‘;
 30     mp[‘5‘]=‘5‘;
 31
 32     mp[‘^‘]=‘^‘;
 33     mp[‘6‘]=‘6‘;
 34
 35     mp[‘&‘]=‘&‘;
 36     mp[‘7‘]=‘7‘;
 37
 38     mp[‘*‘]=‘*‘;
 39     mp[‘8‘]=‘8‘;
 40
 41     mp[‘(‘] = ‘(‘;
 42     mp[‘9‘]=‘9‘;
 43
 44     mp[‘)‘]=‘)‘;
 45     mp[‘0‘]=‘0‘;
 46
 47     mp[‘-‘]=‘[‘;
 48     mp[‘_‘]=‘{‘;
 49
 50     mp[‘=‘]=‘]‘;
 51     mp[‘+‘]=‘}‘;
 52
 53     mp[‘q‘]=‘\‘‘;
 54     mp[‘Q‘]=‘"‘;
 55
 56     mp[‘w‘]=‘,‘;
 57     mp[‘W‘]=‘<‘;
 58
 59     mp[‘e‘]=‘.‘;
 60     mp[‘E‘]=‘>‘;
 61
 62     mp[‘R‘]=‘P‘;
 63     mp[‘r‘]=‘p‘;
 64
 65     mp[‘T‘]=‘Y‘;
 66     mp[‘t‘]=‘y‘;
 67
 68     mp[‘Y‘]=‘F‘;
 69     mp[‘y‘]=‘f‘;
 70
 71     mp[‘U‘]=‘G‘;
 72     mp[‘u‘]=‘g‘;
 73
 74     mp[‘I‘]=‘C‘;
 75     mp[‘i‘]=‘c‘;
 76
 77     mp[‘O‘]=‘R‘;
 78     mp[‘o‘]=‘r‘;
 79
 80     mp[‘P‘]=‘L‘;
 81     mp[‘p‘]=‘l‘;
 82
 83     mp[‘[‘]=‘/‘;
 84     mp[‘{‘]=‘?‘;
 85
 86     mp[‘]‘]=‘=‘;
 87     mp[‘}‘]=‘+‘;
 88
 89     mp[‘\\‘]=‘\\‘;
 90     mp[‘|‘]=‘|‘;
 91
 92     mp[‘A‘]=‘A‘;
 93     mp[‘a‘]=‘a‘;
 94
 95     mp[‘S‘]=‘O‘;
 96     mp[‘s‘]=‘o‘;
 97
 98     mp[‘D‘]=‘E‘;
 99     mp[‘d‘]=‘e‘;
100
101     mp[‘F‘]=‘U‘;
102     mp[‘f‘]=‘u‘;
103
104     mp[‘G‘]=‘I‘;
105     mp[‘g‘]=‘i‘;
106
107     mp[‘H‘]=‘D‘;
108     mp[‘h‘]=‘d‘;
109
110     mp[‘J‘]=‘H‘;
111     mp[‘j‘]=‘h‘;
112
113     mp[‘K‘]=‘T‘;
114     mp[‘k‘]=‘t‘;
115
116     mp[‘L‘]=‘N‘;
117     mp[‘l‘]=‘n‘;
118
119     mp[‘;‘]=‘s‘;
120     mp[‘:‘]=‘S‘;
121
122     mp[‘\‘‘]=‘-‘;
123     mp[‘"‘]=‘_‘;
124
125     mp[‘z‘]=‘;‘;
126     mp[‘Z‘]=‘:‘;
127
128     mp[‘X‘]=‘Q‘;
129     mp[‘x‘]=‘q‘;
130
131     mp[‘C‘]=‘J‘;
132     mp[‘c‘]=‘j‘;
133
134     mp[‘V‘]=‘K‘;
135     mp[‘v‘]=‘k‘;
136
137     mp[‘B‘]=‘X‘;
138     mp[‘b‘]=‘x‘;
139
140     mp[‘N‘]=‘B‘;
141     mp[‘n‘]=‘b‘;
142
143     mp[‘M‘]=‘M‘;
144     mp[‘m‘]=‘m‘;
145
146     mp[‘,‘]=‘w‘;
147     mp[‘<‘]=‘W‘;
148
149
150     mp[‘.‘]=‘v‘;
151     mp[‘>‘]=‘V‘;
152
153     mp[‘/‘]=‘z‘;
154     mp[‘?‘]=‘Z‘;
155
156     mp[‘ ‘]=‘ ‘;
157
158     string s;
159     while(getline(cin,s)){
160         //cout<<s<<endl;
161         for(int i=0;i<s.size();i++){
162             cout<<mp[s[i]];
163         }
164         cout<<endl;
165     }
166     return 0;
167 } 

原文地址:https://www.cnblogs.com/wenzhixin/p/9053731.html

时间: 2024-10-12 11:23:29

OJ Problem Set - 3878 Convert QWERTY to Dvorak的相关文章

模拟 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&

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

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

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

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.

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 K: 负2进制【有技巧构造/待补】

Problem K: 负2进制 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 51 Solved: 6 [Submit][Status][Web Board] Description 如果我16岁,我可以悄悄的说我好喜欢你:如果我26岁,我可以大声告诉你我很爱你:可惜我6岁,我什么都给不了你,我还要上小学. 我们都知道2进制,每一位的权值如下: 1 2 4 8 16 32 64 现在我们定义一种-2进制,每一位的权值如下: 1 -2 4 -8 16

山科SDUST OJ Problem J :连分数

Problem J: 连分数 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 2723  Solved: 801[Submit][Status][Web Board] Description 一个高为n的连分数定义为 . 给出2个数,一个用p/q的方式表达,另一个用高度为n的连分数来表示,请你判断他们是否相等. Input 输入有多组,每组包含两部分用来表示两种形式的分数:第一部分是p和q(1 ≤ q ≤ p ≤ 10^18),表示分数p/q:然后是一