//Random number generator (c) Buffalo Museum of Science, 1996 Richard Zander #include #include #include #include #include #include char testch(char ch); char x[4]; char y; char ch; int top; int chars; int chars2; int taxa; int state; int top2; char oneline[320]; int zero; //used to start rand numbers at zero or 1 FILE *fp; main() { randomize(); clrscr(); again1: cout<< "\nRANDOM DATA SET GENERATOR, which saves results to \"randset.txt\".\n" "\tby R. Zander, Buffalo Museum of Science, Buffalo, NY USA.\n\n" "This will produce pseudo-randomized data sets based on a random seed\n" "number generated from computer clock timing, a Borland C++ function.\n\n" "You select whether zero is to be included in the random numbers,\n" "the values of states (select the top single integer possible),\n" "how many characters (integers in a row) you want,\n" "and number of taxa (columns of random numbers n integers in length).\n\n" " \n\n" "Hit any key to start answering four questions about your data.\n"; ch = getch(); testch(ch); clrscr(); cout<<"1. Do you want to include 0 as a state value (as a random number)? \n" "Y or N? Y = 0 included (any other key = N as default)\n\n"; scanf("%s",&y,1); if (toupper(y) == 'Y') {zero = 0; top2 = 1; } if (toupper(y) != 'Y') {zero = 1;//adding a 1 to results of random() starts numbers at 1. top2 = 0; } cout<9) {cout<<"Hey! It must be less than 10 and greater than 0, please...\n"; goto number2; } if (top <1) {cout<<"Hey! It should be 1 to 9....\n"; goto number2; } cout<<"The top state value possible) is "<=1) {state = (random(top+top2)+zero); { fprintf(fp,"%d",state); chars--; } } fprintf(fp,"\n"); taxa--; if (taxa >0) {goto eachline; } fclose(fp); cout<<"\n\tAgain? y or n or q\n\n"; ch = getch(); testch(ch); clrscr(); if (toupper(ch) == 'Y') {goto again1; } if (toupper(ch) == 'N') { goto endProg; } if (toupper(ch) == 'Q') { goto endProg; } endProg: clrscr(); printf("Thanks for using RANDSET!\n"); return(0); } char testch(char ch) { if (toupper(ch) == 'Q') { cout<<"Goodbye!\n"; exit(0); return(0); } return(0); }