🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Numeros aleatorios con c

#9295
From: eldruida
Date: Mon, 05 Aug 2002 22:23
46 lines
2069 bytes
Xavier Montero wrote:
>>Me puede alguien poner un ejemplo de como crear numeros aleatorios con
>>rand? con turbo c lo se hacer pero en linux no puedo.
> 
> 
> Ah� va el ejemplo que pides.
> 
> xavi@inspire:~/tmp$ cat main.c
> #include <stdio.h>      // for printf()
> #include <stdlib.h>     // for rand()
> 
> void main(void)
> {
>         int i;          // counter
>         float res;      // result
> 
>         for( i=0; i<10; i++ )
>         {
>                 res = float( rand() ) / RAND_MAX;
>                 printf("%f\n", res);
>         }
> }
> xavi@inspire:~/tmp$ g++ main.c
> xavi@inspire:~/tmp$ a.out
> 0.840188
> 0.394383
> 0.783099
> 0.798440
> 0.911647
> 0.197551
> 0.335223
> 0.768230
> 0.277775
> 0.553970
> xavi@inspire:~/tmp$
> 
> 
> 
>>Muchas gracias.
> 
> Muchas de nadas.

Te lo agradezco, no podia conseguirlo.


Saludos.
Technical Details
Message-ID: <3D4EFAD3.6070307@yaonline.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!news-in-sanjose!in.nntp.be!news.telia-iberia.com!news.rediris.es!news.ya.com!yacom!not-for-mail
References: <3D4CD526.4040201@yaonline.es> <3D4ED02F.2602103@dsitelecom.com>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,4b70eab62331a3ee
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-08-05 15:25:04 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!news-in-sanjose!in.nntp.be!news.telia-iberia.com!news.rediris.es!news.ya.com!yacom!not-for-mail
From: eldruida <eldruida@yaonline.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Numeros aleatorios con c
Date: Tue, 06 Aug 2002 00:23:15 +0200
Organization: ya.com internet factory
Lines: 47
Message-ID: <3D4EFAD3.6070307@yaonline.es>
References: <3D4CD526.4040201@yaonline.es> <3D4ED02F.2602103@dsitelecom.com>
NNTP-Posting-Host: 62-151-32-135.premium.ya.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.ya.com 1028586261 9963 62.151.32.135 (5 Aug 2002 22:24:21 GMT)
X-Complaints-To: newsmaster@ya.com
NNTP-Posting-Date: Mon, 5 Aug 2002 22:24:21 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020623 Debian/1.0.0-0.woody.1