//typonet.cpp by Rupert Scammell (fib@lumiere.net). This code is public //domain. // This is version 1.00b1.web1, 5.14.1999. // Please email me if you have any questions or comments. // The latest version of this code can be found at //http://lumiere.net/~fib/code.hmtl // any statement commented with "debug" may be safely removed if you //wish... internal use during development. #include #include #include #include #include #include #include #include using namespace std; int main() { string proxstr[4]={"`~1!2@3#4$5%6^7&8*9(0)-_=+","qQwWeErRtTyYuUiIoOpP[{]}\\|", "aAsSdDfFgGhHjJkKlL;:'","zZxXcCvVbBnNmM,<.>/?"}; string instring,outstring,stringtemp; int howlong; int count=0; int pos; int foundit=string::npos; int arnum; int distort; int maybe; int numtypos=100; int foundtemp; int rowdistort; int already=0; int inversion; ofstream typeout("typofile",ios::app); cout << "Enter a string: "; getline(cin, instring); howlong = instring.length(); cout << instring << " is " << howlong << " characters long." << endl; cout << "Here are some possible typos for this word: " << endl; srand((unsigned int) time(NULL)*rand() ); while (numtypos > 0) { outstring=""; srand((unsigned int) time(NULL)* rand()); //cout << "numtypos: " << numtypos << endl; // debug code while (count < howlong) { srand((unsigned int) time(NULL)* rand()); // cout << "entered count 15000 && maybe < 15900) // greater range= > errors { rowdistort = rand(); inversion = rand(); //cout << "entered maybe > 15000 if " << endl; // debug code distort=9; foundtemp = foundit; while(distort > 4 || distort < 0 || foundtemp < 0) { //cout << "entered the distort rand generator.. distort = //" << distort << endl; //debug code distort = rand(); foundtemp=foundit + distort; foundtemp = 25 - foundtemp; //cout << "in distort rand generator, foundtemp = " << //foundtemp << endl; // debug } if (rowdistort > 1000 && rowdistort < 1900) { //cout << "enter with arnum = " << arnum << endl; //debug if (arnum+distort < 4) { arnum=arnum+distort; already=1; } if (arnum-distort >=0 && already==0) { arnum=arnum-distort; already=0; } //cout << "leave with arnum = " << arnum << endl; //debug } if (inversion > 8000 && inversion < 8500) { // character inversion code here eventually. } foundit=foundit+distort; // distort upwards in the chain.. cout << "ended the if with distort = " << distort << " and foundit= " << foundit << endl; // debug code; } pos = 25-foundit; cout << "pos = 25-foundit returned " << pos << endl; outstring.insert(count,proxstr[arnum].substr(foundit,1) ); count++; } cout << outstring << endl; typeout << outstring << "\n"; numtypos--; count=0; } typeout.close(); return 0; }