Espaços nominais
Variantes
Acções

std::rand

Da cppreference.com
< cpp‎ | numeric‎ | random

 
 
Biblioteca numéricos
Funções matemáticas comuns
De ponto flutuante ambiente
Números complexos
Matrizes numéricas
Pseudo-aleatório de geração de números
Tempo de compilação aritmética racional(C++11)
Genéricos operações numéricas
Original:
Generic numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
 
Pseudo-aleatório de geração de números
Motores e adaptadores de motor
Original:
Engines and engine adaptors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Geradores
Original:
Generators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuições
Original:
Distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuições uniformes
Original:
Uniform distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuições de Bernoulli
Original:
Bernoulli distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuições de Poisson
Original:
Poisson distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuições normais
Original:
Normal distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuições de amostragem
Original:
Sampling distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Seqüências de sementes
Original:
Seed Sequences
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
C biblioteca
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rand
 
Definido no cabeçalho <cstdlib>
int rand();
Retorna uma distribuído uniformemente valor pseudo-aleatório integral entre 0 e RAND_MAX (0 e RAND_MAX incluído).
Original:
Returns a uniformly distributed pseudo-random integral value between 0 and RAND_MAX (0 and RAND_MAX included).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
srand() deve ser chamado antes de quaisquer chamadas para rand() para inicializar o gerador de números aleatórios.
Original:
srand() should be called before any calls to rand() to initialize the random number generator.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar]Parâmetros

(Nenhum)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Valor de retorno

Pseudo-aleatório valor integral entre 0 e RAND_MAX.
Original:
Pseudo-random integral value between 0 and RAND_MAX.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Exemplo

#include <cstdlib>#include <iostream>#include <ctime>   int main(){std::srand(std::time(0));//use current time as seed for random generatorint uniform_random_variable = std::rand();std::cout<<"Uniform random value on [0 "<<RAND_MAX<<"]: "<< uniform_random_variable <<'\n';}

Potencial saída:

Uniform random value on [0 2147483647]: 1373858591

[editar]Veja também

inicializa pseudo-aleatórios gerador de números
Original:
initializes pseudo-random number generator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função)[edit]
close