SDNU 1382.Problem C: WERTYU(水题)
Description? Problem C: WERTYUA common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner. InputInput consists of several lines of text. Each line may contain digits,spaces,upper case letters (except Q,A,Z),or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab,BackSp,Control, etc.] are not represented in the input.? Output
You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.
Sample InputO S,GOMR YPFSU/ Sample OutputI AM FINE TODAY. Source
Waterloo local 2001.01.27
#include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <map> using namespace std; #define ll long long const int inf = 0x3f3f3f3f; const int mod = 1e9+7; string s; int main() { while(getline(cin,s)) { int len = s.size(); for(int i = 0; i<len; i++) { if(s[i] == ‘1‘)printf("`"); else if(s[i] == ‘2‘)printf("1"); else if(s[i] == ‘3‘)printf("2"); else if(s[i] == ‘4‘)printf("3"); else if(s[i] == ‘5‘)printf("4"); else if(s[i] == ‘6‘)printf("5"); else if(s[i] == ‘7‘)printf("6"); else if(s[i] == ‘8‘)printf("7"); else if(s[i] == ‘9‘)printf("8"); else if(s[i] == ‘0‘)printf("9"); else if(s[i] == ‘-‘)printf("0"); else if(s[i] == ‘=‘)printf("-"); else if(s[i] == ‘W‘)printf("Q"); else if(s[i] == ‘E‘)printf("W"); else if(s[i] == ‘R‘)printf("E"); else if(s[i] == ‘T‘)printf("R"); else if(s[i] == ‘Y‘)printf("T"); else if(s[i] == ‘U‘)printf("Y"); else if(s[i] == ‘I‘)printf("U"); else if(s[i] == ‘O‘)printf("I"); else if(s[i] == ‘P‘)printf("O"); else if(s[i] == ‘[‘)printf("P"); else if(s[i] == ‘]‘)printf("["); else if(s[i] == 92)printf("]");/// else if(s[i] == ‘S‘)printf("A"); else if(s[i] == ‘D‘)printf("S"); else if(s[i] == ‘F‘)printf("D"); else if(s[i] == ‘G‘)printf("F"); else if(s[i] == ‘H‘)printf("G"); else if(s[i] == ‘J‘)printf("H"); else if(s[i] == ‘K‘)printf("J"); else if(s[i] == ‘L‘)printf("K"); else if(s[i] == ‘;‘)printf("L"); else if(s[i] == 39)printf(";"); else if(s[i] == ‘X‘)printf("Z"); else if(s[i] == ‘C‘)printf("X"); else if(s[i] == ‘V‘)printf("C"); else if(s[i] == ‘B‘)printf("V"); else if(s[i] == ‘N‘)printf("B"); else if(s[i] == ‘M‘)printf("N"); else if(s[i] == ‘,‘)printf("M"); else if(s[i] == ‘.‘)printf(","); else if(s[i] == ‘/‘)printf("."); else if(s[i] == ‘ ‘)printf(" "); } printf("n"); } return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |