Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main () {
- int j;
- /*
- srand inicializa o gerador de numeros aleatorios
- deve ser utilizado apenas uma vez
- unsigned = 0 até 4.294.967.295
- */
- srand( (unsigned)time( NULL ) );
- // Gera numeros aleatorios grandes
- j = rand();
- cout <<" Numero Aleatorio : " << j << endl;
- // Gera numeros aleatorios de 1 ate 100
- j = rand() % 100 + 1;
- cout <<" Numero Aleatorio : " << j << endl;
- // Gera numeros aleatorios de 2000 até 2030
- j = rand() % 30 + 2000;
- cout <<" Numero Aleatorio : " << j << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement