0
#include <string>
#include <ctime>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>

using namespace std;



`static unsigned int Q[41790],indx=41790,carry=362436,xcng=1236789,xs=521288629; 
unsigned int refill()// refill f(n) for SuperKISS 
{ 
int i; 
unsigned long long t; 
for (i=0;i<41790;i++) 
{ 
t = 7010176ULL * Q[i] + carry; 
carry = (t>>32); 
Q[i] = ~t; 
} 
indx=1; 
return (Q[0]); 
} 
unsigned int SuperKISS() 
{ 
xcng = 69069 * xcng + 123; 
xs ^= xs<<13; 
xs ^= xs>>17; 
xs ^= xs>>5; 
return (indx<41790 ? Q[indx++] : refill()) + xcng + xs; 
}

char createRandstr(string alphaRand) 
{ 
int stringLength = sizeof(alphaRand) - 1; 
//for (int i=0;i<4;i++) 
//{ 
char randstrn = alphaRand[rand() % stringLength]; 
return randstrn; 
//}

} 
' 
int main() 
{

//mt19937 mt;//mersenne twister 2^(19937-1) does not work on on compilers w/o C++11
//mt.seed(time(0));
string alphaRand = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
srand(SuperKISS()*time(0));//found it online @ www0.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG
int numofstrings = 10000;
ofstream myfile("/Users/eknargarcia/Projects/ScrabbleWordFinder/ScrabbleWordFinder/output.txt");

if (myfile.is_open())
{
    for (int i=0; i < numofstrings; i++)
    {
        cout << createRandstr(alphaRand) << createRandstr(alphaRand) << createRandstr(alphaRand) << createRandstr(alphaRand) << endl;
        myfile << createRandstr(alphaRand) << createRandstr(alphaRand) << createRandstr(alphaRand) << createRandstr(alphaRand) << endl;
        myfile.clear();
    }
    myfile.close();
    cout << endl;
    cout << "Done printing to file " << endl;
}
else cout << "Unable to open file" << endl;
exit(1); // terminate with error
return 0;
}
2
Contributors
1
Reply
11
Views
4 Years
Discussion Span
Last Post by Ancient Dragon
0

What's the problem? You stated what it is supposed to do but failed to say what it doesn't do. Don't expect us to guess what you want.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.