//**************************************************************************** //Programmer: David Hanchera //Assignment: Lab1__Generate, sort and output random numbers //Due Date: 2-16-2000 //**************************************************************************** #include #include #include #include #define MIN 1000000 #define MODBY 100000000 ifstream infile("a:lab1file.txt"); ofstream outfile("a:lab1file.txt"); ofstream toprint("a:print.txt"); void generate(unsigned long []); //prototypes void insertsort(unsigned long []); void no_dups(unsigned long []); void output(); void main(void) { int i; unsigned long MYRAND[3000]; generate(MYRAND); insertsort(MYRAND); no_dups(MYRAND); output(); } //**************************************************************************** //Module: generate //Pre: Array of 3000 unsigned longs has been created //Post: Array filled with random numbers between 1000000-99999999 //**************************************************************************** void generate(unsigned long MYRAND[]) { int i; unsigned long temp1, temp2; for(i=0;i<3000;i++) { srand( (unsigned long)time(NULL) ); //range 1000000-99999999 temp1=(rand())%3023; srand( (unsigned long)time(NULL) ); temp2=(rand()*(i+1))%32749; MYRAND[i]=temp1*temp2; MYRAND[i]=MYRAND[i]%MODBY; if(MYRAND[i]=0;place--) { MYRAND[place+1]=MYRAND[place]; if( place==0 || ( MYRAND[place-1] <= current) ) break; } MYRAND[place]=current; } } } //**************************************************************************** //Module: no_dups //Pre: Array of 3000 random numbers has been created //Post: Duplicate numbers in array have been nulled out, then out to file //**************************************************************************** void no_dups(unsigned long MYRAND[]) { int i; for(i=0;i<3000;i++) { if( i==(i+1) ) MYRAND[i]=NULL; if(MYRAND[i]!=NULL) outfile<>temp; toprint<