<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
		<id>https://1984.lsi.us.es/wiki-c/index.php?action=history&amp;feed=atom&amp;title=Random</id>
		<title>Random - Historial de revisiones</title>
		<link rel="self" type="application/atom+xml" href="https://1984.lsi.us.es/wiki-c/index.php?action=history&amp;feed=atom&amp;title=Random"/>
		<link rel="alternate" type="text/html" href="https://1984.lsi.us.es/wiki-c/index.php?title=Random&amp;action=history"/>
		<updated>2026-05-07T22:25:24Z</updated>
		<subtitle>Historial de revisiones para esta página en el wiki</subtitle>
		<generator>MediaWiki 1.29.0</generator>

	<entry>
		<id>https://1984.lsi.us.es/wiki-c/index.php?title=Random&amp;diff=118&amp;oldid=prev</id>
		<title>Carfalgar: Página creada con «Podeis usar las funciones rand, srand y time para inicializar vuestro mundo con células con posiciones aleatorias.  La función &lt;syntaxhighlight lang=&quot;c&quot; enclose=&quot;none&quot;&gt;in...»</title>
		<link rel="alternate" type="text/html" href="https://1984.lsi.us.es/wiki-c/index.php?title=Random&amp;diff=118&amp;oldid=prev"/>
				<updated>2016-04-11T10:00:17Z</updated>
		
		<summary type="html">&lt;p&gt;Página creada con «Podeis usar las funciones rand, srand y time para inicializar vuestro mundo con células con posiciones aleatorias.  La función &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; enclose=&amp;quot;none&amp;quot;&amp;gt;in...»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nueva&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Podeis usar las funciones rand, srand y time para inicializar vuestro mundo con células con posiciones aleatorias.&lt;br /&gt;
&lt;br /&gt;
La función &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; enclose=&amp;quot;none&amp;quot;&amp;gt;int rand()&amp;lt;/syntaxhighlight&amp;gt; devuelve un número distinto &amp;quot;aleatorio&amp;quot; cada vez que la llamamos. Sin embargo, podreis comprobar que siempre devuelve la misma secuencia de números, esto es porque se genera mediante un algorito matemático en base a un número inicial: '''semilla'''. Mientras esta semilla sea la misma, siempre generará la misma secuencia. Lo que se suele hacer es establecer la semilla con la hora del sistema (en segundos desde el Jueves 1 de Enero de 1970) al iniciar la ejecución del programa, de esta forma, cada vez que se ejecuta devolverá una secuencia aleatoria distinta. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aquí podemos ver un ejemplo de uso de la función rand() ([http://codepad.org/DACjzgJX ver ejecución]):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line=&amp;quot;1&amp;quot; &amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
float frand()&lt;br /&gt;
{&lt;br /&gt;
    return (float)rand()/RAND_MAX;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int rrand(int from, int to)&lt;br /&gt;
{&lt;br /&gt;
    return rand()%(to - from + 1) + from;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    int i;&lt;br /&gt;
&lt;br /&gt;
    srand(time(0)); //use current time as seed for random generator&lt;br /&gt;
    &lt;br /&gt;
    for (i = 10; i &amp;gt; 0; i--)&lt;br /&gt;
        printf(&amp;quot;frand = %f\trrand = %d\n&amp;quot;, frand(), rrand(3, 15));&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Más información:  http://en.cppreference.com/w/c/numeric/random/rand&lt;/div&gt;</summary>
		<author><name>Carfalgar</name></author>	</entry>

	</feed>