🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #15356

Re: Números aleatorios

#15356
From: kuantiko
Date: Mon, 10 Jul 2000 00:00
44 lines
1933 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

drf escribió:
> No se a que funciones os refereis, ni de que lenguaje de
> programacion,

	En C, de la función rand().

> pero un lenguaje programacion cualquiera tiene una
> funcion que genera numeros aleatorios entre 0 y 1. Una vez obtenido
> el numero con una sencilla regla de 3 se le pone en el rango
> adecuado.

	No, rand() genera un número entre 0 y RAND_MAX, pero si se quiere,
se puede hace una macro:

#define aleatorio(min, max) ((min)+(int)((double)rand()/(double)RAND_MAX*(max)))

Un saludo.
- -- 
 
Jesús Carrete Montaña ----> KUANTIKO
 ___________________________________________ 
|    .~.                                    |
|    /V\     jrcarmon(arroba)teleline.es    |
|   // \\    Linux Registered               |
|  /(   )\   User #158442                   |
|   ^`~'^                                   |
|___________________________________________|

Clave pública PGP disponible por e-mail.

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1i for non-commercial use <http://www.pgpi.com/>

iQA/AwUBOWn73lXBzV6UX+HYEQIWSgCfZ4ygoBQ+8zkcsfQf1dBhkgXAq/4An1Yk
I7/kQRQlNrhMZQP0PqhFVO+n
=YyjB
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <396A0A10.55D9F7D7@teleline.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <E_H95.144$pA2.4012@m2newsread.uni2.es> <396756C2.8E2404AE@en.ninguna.parte> <39678ED7.220F6D37@teleline.es> <8kcbm1$h1j$1@talia.mad.ttd.net>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,9e48787536054c7
X-Google-Attributes: gidf86c8,public
From: kuantiko <jrcarmon@teleline.es>
Subject: Re: Números aleatorios
Date: 2000/07/10
Message-ID: <396A0A10.55D9F7D7@teleline.es>
X-Deja-AN: 644686890
Content-Transfer-Encoding: quoted-printable
References: <E_H95.144$pA2.4012@m2newsread.uni2.es> <396756C2.8E2404AE@en.ninguna.parte> <39678ED7.220F6D37@teleline.es> <8kcbm1$h1j$1@talia.mad.ttd.net>
X-Accept-Language: es
Content-Type: text/plain; charset=iso-8859-1
Organization: Quanta Studios
Mime-Version: 1.0
Reply-To: jrcarmon@teleline.es
Newsgroups: es.comp.os.linux.programacion