std::uniform_int_distribution
De cppreference.com
|
|
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. |
| Defined in header <random>
|
||
| template< class IntType = int > class uniform_int_distribution; |
(ya que C + +11) | |
Produce i aleatoria valores enteros, distribuida uniformemente en el
[a, b] intervalo cerrado, es decir, distribuidos de acuerdo con la función de probabilidad 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
[editar] Tipos de miembros
| Miembro de tipo
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
|
el tipo del conjunto de parámetros, sin especificar
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. |
[editar] Las funciones miembro
| construye nueva distribución Original: constructs new distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| restablece el estado interno de la distribución Original: resets the internal state of the distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
Original: Generation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| genera el siguiente número aleatorio en la distribución Original: generates the next random number in the distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
Original: Characteristics The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| devuelve el a parámetro de distribución (valor mínimo) Original: returns the a distribution parameter (minimum value) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve el b parámetro de distribución (valor máximo) Original: returns the b distribution parameter (maximum value) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| obtiene o establece el objeto de parámetro de distribución Original: gets or sets the distribution parameter object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve el valor mínimo potencialmente generado Original: returns the minimum potentially generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve el valor máximo potencialmente generado Original: returns the maximum potentially generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
[editar] Terceros funciones
| compara dos objetos de distribución Original: compares two distribution objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función) | |
| realiza flujo de entrada y salida en la distribución de números pseudo-aleatorios Original: performs stream input and output on pseudo-random number distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función) | |
[editar] Ejemplo
Este programa simula tirar dados de 6 caras .
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'; }
Possible output:
1 1 6 5 2 2 5 5 6 2