博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
模拟 ZOJ 3878 Convert QWERTY to Dvorak
阅读量:4973 次
发布时间:2019-06-12

本文共 3344 字,大约阅读时间需要 11 分钟。

 

1 /* 2     模拟:手敲map一一映射,累! 3         除了忘记读入字符串不能用gets用getline外还是很顺利的AC了:) 4 */ 5 #include 
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 using namespace std;16 17 const int MAXN = 1e2 + 10;18 const int INF = 0x3f3f3f3f;19 map
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 Dvorak75 {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 123456789094 `~!@#$%^&*()+_-={}[]:"'<>,.?/\|95 ABCDEFuvwxyz96 AXJE>Ugk,qf;97 */
1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 using namespace std;12 #define ls 2*i13 #define rs 2*i+114 #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 long19 const double pi = acos(-1.0);20 #define Len 2000521 #define mod 1999999722 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 }
网上题解,两行,给跪了!

 

转载于:https://www.cnblogs.com/Running-Time/p/4457671.html

你可能感兴趣的文章
结对编程项目-四则运算整体总结
查看>>
Android studio怎么修改文件名
查看>>
sass学习笔记-安装
查看>>
多缓存并存
查看>>
Flask (二) cookie 与 session 模型
查看>>
修改添加网址的教程文件名
查看>>
hdu 1045:Fire Net(DFS经典题)
查看>>
[BZOJ 1017][JSOI2008]魔兽地图DotR(树形Dp)
查看>>
裁剪图片
查看>>
数据结构实习 problem L 由二叉树的中序层序重建二叉树
查看>>
VS中展开和折叠代码
查看>>
如何确定VS编译器版本
查看>>
设置PL/SQL 快捷键
查看>>
个人阅读作业7
查看>>
转载:深入浅出Zookeeper
查看>>
GMA Round 1 新程序
查看>>
node anyproxy ssi简易支持
查看>>
编译预处理指令:文件包含指令、宏定义指令、条件编译指令
查看>>
PHP函数 ------ ctype_alnum
查看>>
网站安全
查看>>