Originally posted by Ikurik
I tried your suggestion, and while it does accomplish the goal of excluding 0 it does something else also. I ran the program multiple times with your suggestion and the re sults i got were something like this:
1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4,1, 1,1, 2, 2, ect.
Basically what i am trying to say is that it doesnt look to random to me. It looks like it is just making some kind of sequence towards 4 and then starting over again at 1.
Bad luck, I guess.
Try making this
Code:
for (int i=0; i<1; i++) {
  cout << rand() % 5 << endl;
}
into this:
Code:
for (int i=0;i < 10; ++i) {
  cout << rand()%4 + 1 << endl;
}
So it prints out more often per program execution.