Don’t use srand
inside the loop, use it only once, e.g. at the start of main()
. And srand()
is exactly how you reset this.
More Related Contents:
- C++ Reading an unknown number of integers to cin and outputting the sum
- C++ while loop resetting variables?
- For loop with an array
- How can I use the output of a rand function, simulating 2 die rolls?
- Random generation of numbers? [closed]
- c++ skipping the if and for loops?
- Generating random integer from a range
- Weighted random numbers
- Why is the use of rand() considered bad?
- Random number generation in C++11: how to generate, how does it work? [closed]
- How to succinctly, portably, and thoroughly seed the mt19937 PRNG?
- How do I create a random alpha-numeric string in C++?
- Rand() % 14 only generates the values 6 or 13
- Random array generation with no duplicates
- Random number c++ in some range [duplicate]
- rand() generating the same number – even with srand(time(NULL)) in my main!
- Generating m distinct random numbers in the range [0..n-1]
- Random number generator that produces a power-law distribution?
- How to generate random variable names in C++ using macros?
- Is there ever a need for a “do {…} while ( )” loop?
- Random output different between implementations
- How does OpenMP handle nested loops?
- Reusing thread in loop c++
- Same random numbers every time I run the program
- What is a good random number generator for a game?
- What is a seed in terms of generating a random number? [duplicate]
- stl random distributions and portability
- How to make sure that std::random_shuffle always produces a different result?
- How does calling srand more than once affect the quality of randomness?
- What difference between rand() and random() functions?