#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;
}
eig132062 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.