All pastes #758251 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-02 00:54 UTC
rendered paste body
#include <iostream>
#include <string>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main()
{
	int ShiftCount;
	string Text;

	const string Keys[4] = {"`1234567890-=\\",
							"	qwertyuiop[]",
							"asdfghjkl;'",
							"zxcvbnm,./"};

	cout << "Enter text:" << endl;
	getline(cin, Text);

	cout << endl << "QWERTYShift by: ";
	cin >> ShiftCount;

	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;
	system("pause");
}