Friday, June 27, 2008

C++ get random number

#include // For time()
#include // For srand() and rand()
void foo() {
srand(time(0)); // Initialize random number generator.
int r = (rand() % 10) + 1;
}

No comments: