#include #include #include #include using namespace std; #define USE_CL_ARGS int main(int argc, char** argv) { int ShiftCount; string Text; const string Keys[4] = {"`1234567890-=\\", " qwertyuiop[]", "asdfghjkl;'", "zxcvbnm,./"}; #ifdef USE_CL_ARGS if(argc != 3) { cout << "Usage: qwertyshift \"Text\" shiftcount"; return 0; } Text = argv[1]; ShiftCount = atoi(argv[2]); #else cout << "Enter text:" << endl; getline(cin, Text); cout << endl << "QWERTYShift by: "; cin >> ShiftCount; #endif for(string::iterator i = Text.begin() ; i != Text.end() ; i++) { int Row = -1; int Key = -1; for(int j = 0 ; j < 4 ; j++) { for(int k = 0 ; k != Keys[j].length() ; k++) { if(Keys[j][k] == *i) { Key = k; Row = j; goto loop_end; } } } loop_end: if(Key != -1 && Row != -1) { Key = (Key + ShiftCount) % Keys[Row].length(); *i = Keys[Row][Key]; } } cout << endl << Text << endl; return 0; }