srand(time(NULL));usually should be done once at the beginning main()and never again.
, , , rolld6 , , .
:
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <stdlib.h>
int rolld6 (void) {
return rand() % 6 + 1;
}
int main (void) {
srand (time (NULL));
std::cout << rolld6() << std::endl;
std::cout << rolld6() << std::endl;
system ("PAUSE");
return 0;
}
, , - . , . , script, , .
, system() cmd.exe script, , - :
1
5
1
5
1
5
, , , .