ZOJ 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 }
欢迎交流,共同进步——