不依赖数组(字符串版)

来源:互联网 发布:ios存储数据的方式 编辑:程序博客网 时间:2024/06/05 18:08

同样是不依赖于数组,逐个输入字符,逐个进行操作


Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a brokenCaps Lock key, so Edward never presses the brokenCaps Lock key. Luckily, all the other keys on the QWERTY keyboard work well. Every day, he has a lot of documents to type. Thus he needs a converter to translate QWERTY into Dvorak. Can you help him?

The QWERTY Layout and the Dvorak Layout are in the following:

Qwerty LayoutThe QWERTY Layout
Dvorak LayoutThe Dvorak Layout

Input

A QWERTY document Edward typed. The document has no more than 100 kibibytes. And there are no invalid characters in the document.

Output

The Dvorak document.

Sample Input
Jgw Gqm Andpw a H.soav Patsfk f;doeNfk Gq.d slpt a X,dokt vdtnsaoheKjd yspps,glu pgld; aod yso kd;kgluZ1234567890`~!@#$%^&*()}"']_+-=ZQqWEwe{[\|ANIHDYf.,bt/ABCDEFuvwxyz
Sample Output
Hi, I'm Abel, a Dvorak Layout user.But I've only a Qwerty keyboard.The following lines are for testing:1234567890`~!@#$%^&*()+_-={}[]:"'<>,.?/\|ABCDEFuvwxyzAXJE>Ugk,qf;


题目大意:如果用上面键盘输入一串字符,就按照下面的键盘顺序把这串字符输出出来;用下面的键盘输入一串字符同理







 #include <iostream>      #include <stdio.h>      #include <string.h>      #include <stack>      #include <queue>      #include <map>      #include <set>      #include <vector>      #include <math.h>      #include <algorithm>      using namespace std;      #define ls 2*i      #define rs 2*i+1      #define up(i,x,y) for(i=x;i<=y;i++)      #define down(i,x,y) for(i=x;i>=y;i--)      #define mem(a,x) memset(a,x,sizeof(a))      #define w(a) while(a)      #define LL long long      const double pi = acos(-1.0);      #define Len 20005      #define mod 19999997      const int INF = 0x3f3f3f3f;            char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"};      char s2[]= {"[]{}',.pyfgcrl/=\"<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};      char c;            char print(char c)      {          for(int i=0; s1[i]; i++)              if(s1[i]==c)                  return s2[i];          return c;      }      int main()      {          w(~scanf("%c",&c))          printf("%c",print(c));                return 0;      }  

原创粉丝点击