🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.c++
Article #145

Función para Aleatorios.

#145
From: R.G.A.M.
Date: Sun, 07 Oct 2007 21:09
17 lines
1761 bytes
Creé una función que devuelva un valor entero aleatorio entre dos
dados. He aquí el código de la misma:

int Aleatorio_Entre (int num1, int num2)
{
    srand((unsigned)time(NULL));
    int aleatorio = rand() % (num2-num1+1) + num1;
    return aleatorio;
}

Funciona relativamente bien (efectivamente, obtiene un valor aleatorio
entre los dos dados), pero siempre devuelve el mismo valor cada vez
que se la invoca.

¿Podría ayudarme alguien, por favor? Revisé antes en el foro para
encontrar alguna ayuda, pero no tuve éxito. Muchas gracias con
anticipación.
Technical Details
Message-ID: <1191791399.660205.170130@o80g2000hse.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!o80g2000hse.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f53ec,cfee6b0bbd09c49,start
X-Google-Attributes: gidf53ec,public,usenet
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!o80g2000hse.googlegroups.com!not-for-mail
From:  "R.G.A.M." <rgam1989@gmail.com>
Newsgroups: es.comp.lenguajes.c++
Subject: Función para Aleatorios.
Date: Sun, 07 Oct 2007 21:09:59 -0000
Organization: http://groups.google.com
Lines: 18
Message-ID: <1191791399.660205.170130@o80g2000hse.googlegroups.com>
NNTP-Posting-Host: 190.52.148.127
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1191791399 7910 127.0.0.1 (7 Oct 2007 21:09:59 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 7 Oct 2007 21:09:59 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.6;MEGAUPLOAD 1.0,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: o80g2000hse.googlegroups.com; posting-host=190.52.148.127;
   posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0