Diferenças entre edições de "cpp/numeric/random/uniform int distribution"
Da cppreference.com
m (uma edição: Translate from the English version) |
m (r2.7.3) (Robô: A adicionar: de, en, es, fr, it, ja, ru, zh) |
||
Linha 60: | Linha 60: | ||
1 1 6 5 2 2 5 5 6 2 | 1 1 6 5 2 2 5 5 6 2 | ||
}} | }} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ |
Revisão das 16h57min de 2 de novembro de 2012
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Definido no cabeçalho <random>
|
||
template< class IntType = int > class uniform_int_distribution; |
(desde C++11) | |
Produz aleatória i valores inteiros, distribuídos uniformemente no intervalo
[a, b]
fechado, isto é, distribuídas de acordo com a função de probabilidade discreta Original:
Produces random integer values i, uniformly distributed on the closed interval
[a, b]
, that is, distributed according to the discrete probability function The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- P(i|a,b) =
.1 b − a + 1
Tipos de membro
Tipo de membro
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
result_type
|
IntType |
param_type
|
o tipo do conjunto de parâmetros, não especificado
Original: the type of the parameter set, unspecified The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Funções de membro
Original: Generation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
Original: Characteristics The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Não-membros funções
Exemplo
Este programa simula jogando seis lados dados .
Original:
This program simulates throwing 6-sided dice.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <random> #include <iostream> int main() { std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> dis(1, 6); for(int n=0; n<10; ++n) std::cout << dis(gen) << ' '; std::cout << '\n'; }
Potencial saída:
1 1 6 5 2 2 5 5 6 2