J - Convert QWERTY to Dvorak
程序员文章站
2022-05-12 11:44:14
...
思路:
把两种键盘的符号都存到字符串中,再寻找就可以了,刚开始用c++一直wa,后来改了c就a了。
#include<stdio.h>
#include<cstring>
using namespace std;
char mapp;
char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"};
char s2[]= {"[]{}',.pyfgcrl/=\"<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};
int main()
{
while(scanf("%c",&mapp)!=EOF)
{
int flag=0;
int len=strlen(s1);
for(int i=0;i<len;i++)
{
if(s1[i]==mapp)
{
flag=1;
printf("%c",s2[i]);
}
}
if(flag==0)
printf("%c",mapp);
}
return 0;
}