#include using namespace std; #include "prompt.h" #include "tvector.h" #include "randgen.h" int main() { int num; int k; RandGen random; tvector randStats(7); // vector for counters int n = PromptRange("how many random numbers",1,20000); for(k=0; k <= 6; k++) // initialize counters to zero { randStats[k] = 0; } for(k=0; k < n; k++) // pick all random numbers { num = random.RandInt(7); // between 0 and 6 randStats[num]++; // and increment corresponding counter } cout << "number\t\t# of occurrences" << endl; for(k=0; k <= 6; k++) { cout << k << "\t\t" << randStats[k] << endl; } return 0; }