<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Zufallszahlen]]></title><description><![CDATA[<p>Möchte Zufallszahlen nach der linearen Kongruenzmethode erzeugen.</p>
<p>mein Program:1-12;<br />
a=0;</p>
<p>double rand(int a)<br />
{<br />
double m=381.0;<br />
int b=19;<br />
double d=0;<br />
d=((a*b+1)%(int)m)/m;</p>
<p>return d;<br />
}</p>
<p>a=(rand(a)*11)+1;</p>
<p>Gibt immer nur zwei aus??</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/179511/zufallszahlen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 12:28:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/179511.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Apr 2007 17:24:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zufallszahlen on Sun, 22 Apr 2007 17:24:53 GMT]]></title><description><![CDATA[<p>Möchte Zufallszahlen nach der linearen Kongruenzmethode erzeugen.</p>
<p>mein Program:1-12;<br />
a=0;</p>
<p>double rand(int a)<br />
{<br />
double m=381.0;<br />
int b=19;<br />
double d=0;<br />
d=((a*b+1)%(int)m)/m;</p>
<p>return d;<br />
}</p>
<p>a=(rand(a)*11)+1;</p>
<p>Gibt immer nur zwei aus??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271290</guid><dc:creator><![CDATA[Titu]]></dc:creator><pubDate>Sun, 22 Apr 2007 17:24:53 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Sun, 22 Apr 2007 22:22:39 GMT]]></title><description><![CDATA[<p>Beim start des programms wirst du mit rand immer die selbe zufallszahlenfolge bekommen. Der Computer geht dort ja nach einem musster vor. du solltest die zufallszahl bzw rand mit der Uhrzeit verbinden weil diese mit sicherheit bei jedem programmstart anders ist.</p>
<p>initialisier das mit</p>
<pre><code class="language-cpp">srand(time(NULL));
</code></pre>
<p>vielleicht hilft dir das ja weiter</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;cmath&gt;

using namespace std;

int main()
{
    srand(time(NULL)); // Zufallszahl initialisieren
    cout &lt;&lt; &quot;Zufallszahl: &quot; &lt;&lt; (rand()%100)+1 &lt;&lt; endl; // Zufallszahl 0 - 100

    system(&quot;Pause&quot;);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1271426</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271426</guid><dc:creator><![CDATA[Sebbo]]></dc:creator><pubDate>Sun, 22 Apr 2007 22:22:39 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Sun, 22 Apr 2007 22:40:25 GMT]]></title><description><![CDATA[<p>Sebbo, er schreibt einen eigenen Generator,also seine eigene rand() Funktion nach einem Algorithmus, der sich &quot;linearen Kongruenzmethode&quot; nennt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271429</guid><dc:creator><![CDATA[_||_]]></dc:creator><pubDate>Sun, 22 Apr 2007 22:40:25 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Mon, 23 Apr 2007 02:38:30 GMT]]></title><description><![CDATA[<p>@Titu: wieso mischt du ints und doubles?</p>
<p>LC macht man normalerweise mit Integers, und zwar ca. so:</p>
<pre><code class="language-cpp">const unsigned a = ...;
const unsigned b = ...;
const unsigned c = ...;

unsigned generator(unsigned seed)
{
    seed = (seed * a + b) % c;
    return seed;
}
</code></pre>
<p>Noch besser: pack es in eine Klasse, so dass du &quot;seed&quot; nicht immer mit rumreichen musst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271435</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Apr 2007 02:38:30 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Mon, 23 Apr 2007 12:31:40 GMT]]></title><description><![CDATA[<p>hmm guckt mal bitte ins Mag ... da steht dazu nen kleiner Artikel ... das ihr alle sowas wie die Suche nicht nutzen könnt kotzt schon ziemlich an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271717</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271717</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Mon, 23 Apr 2007 12:31:40 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Tue, 24 Apr 2007 01:16:09 GMT]]></title><description><![CDATA[<p>Wen meinst du mit &quot;ihr alle&quot;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272105</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 24 Apr 2007 01:16:09 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Tue, 24 Apr 2007 06:22:41 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Wen meinst du mit &quot;ihr alle&quot;?</p>
</blockquote>
<p>Alle, die sich angesprochen fuehlen. f'`8k</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox290872" /><label for="checkbox290872"></label></div><a href="http://tggc.tg.funpic.de/index.php?cat=8&amp;page=5" rel="nofollow">Autocogito</a></p>
<p>Gruß, TGGC (<a href="http://www.games-net.de/hosted/tggc" rel="nofollow">making great games since 1992</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272138</guid><dc:creator><![CDATA[TGGC]]></dc:creator><pubDate>Tue, 24 Apr 2007 06:22:41 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Tue, 24 Apr 2007 15:38:20 GMT]]></title><description><![CDATA[<p>TGGC, sei ruhig, mit dir redet keiner.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272563</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 24 Apr 2007 15:38:20 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Tue, 24 Apr 2007 15:43:50 GMT]]></title><description><![CDATA[<p>Lass mal deinen Frust nicht an mir aus. Warum musst du immer Streit suchen? f'`8k</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox290873" /><label for="checkbox290873"></label></div><a href="http://tggc.tg.funpic.de/index.php?cat=8&amp;page=5" rel="nofollow">Autocogito</a></p>
<p>Gruß, TGGC (<a href="http://www.games-net.de/hosted/tggc" rel="nofollow">making great games since 1992</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272573</guid><dc:creator><![CDATA[TGGC]]></dc:creator><pubDate>Tue, 24 Apr 2007 15:43:50 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Tue, 24 Apr 2007 21:19:20 GMT]]></title><description><![CDATA[<p>hi,<br />
anbei ein einfacher Randomgenerator, der gleichverteilte Pseudozufallszahlen nach der Lehmer'schen linearen Kongruenzmethode aus dem Interval 0..s-1 berechnet, so wie hustbaer vorgeschlagen hat:</p>
<pre><code class="language-cpp">unsigned long lehmer(unsigned long s)
{   static unsigned long a = 1, b = 4194301, c = 2147483647, z = b;  
    z = (a + b * z) % c ;
    return z % s;
}
</code></pre>
<p>Die Ganzzahl-Konstanten a,b,c können NICHT frei gewählt werden. Theorie dazu kannst du z.B. beim Altvater Donald Knuth, The Art ... Bd.3 finden. Wichtig ist, dass c eine große Primzahl ist, damit die Periode groß wird, theoretisch max. c-1. In diesem Beispiel ist c = (2^31)-1 (berühmte von Euler nachgewiesene Mersennezahl:).<br />
Google mal nach Alan Miller, der hat einen phantastischen Randomgenerator mit Periode 10^171 geschrieben.<br />
viel spass,<br />
tesuji</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272850</guid><dc:creator><![CDATA[tesuji]]></dc:creator><pubDate>Tue, 24 Apr 2007 21:19:20 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahlen on Wed, 25 Apr 2007 23:03:31 GMT]]></title><description><![CDATA[<p>TGGC schrieb:</p>
<blockquote>
<p>Lass mal deinen Frust nicht an mir aus. Warum musst du immer Streit suchen? f'`8k</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox290874" /><label for="checkbox290874"></label></div><a href="http://tggc.tg.funpic.de/index.php?cat=8&amp;page=5" rel="nofollow">Autocogito</a></p>
<p>Gruß, TGGC (<a href="http://www.games-net.de/hosted/tggc" rel="nofollow">making great games since 1992</a>)</p>
</blockquote>
<p>lol</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1273613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1273613</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 25 Apr 2007 23:03:31 GMT</pubDate></item></channel></rss>