<?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[Zufallszahl zwichen x und y]]></title><description><![CDATA[<p>Hallo,<br />
ich brauche für mein kleines text rpg den 'befehl'das eine zufallszahl zwichen<br />
zB. 50 und 100 generiert wird</p>
<p>int zufallszahl = rand()%100</p>
<p>soweit bin ich....</p>
<p>danke imn voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/270123/zufallszahl-zwichen-x-und-y</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 13:46:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/270123.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Jul 2010 19:29:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Tue, 06 Jul 2010 19:29:50 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich brauche für mein kleines text rpg den 'befehl'das eine zufallszahl zwichen<br />
zB. 50 und 100 generiert wird</p>
<p>int zufallszahl = rand()%100</p>
<p>soweit bin ich....</p>
<p>danke imn voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922441</guid><dc:creator><![CDATA[DominikEbach]]></dc:creator><pubDate>Tue, 06 Jul 2010 19:29:50 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Tue, 06 Jul 2010 19:32:35 GMT]]></title><description><![CDATA[<p>Nimm eine Zufallszahl zwischen 0 und 50 und addiere 50.</p>
<p>P.S. <code>rand()%100</code> sind übrigens Zahlen zwischen 0 und 99 (einschließlich).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922446</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922446</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 06 Jul 2010 19:32:35 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Tue, 06 Jul 2010 21:20:21 GMT]]></title><description><![CDATA[<p>RAND_MAX ist eine Konstante, die die maximale Zufallszahl generiert, also ist</p>
<pre><code class="language-cpp">rand()/RAND_MAX
</code></pre>
<p>eine Zufallszahl zwischen 0 und 1 und dann ist</p>
<pre><code class="language-cpp">50+rand()/RAND_MAX*50
</code></pre>
<p>eine Zufallszahl zwischen 50 und 100.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922473</guid><dc:creator><![CDATA[Max3000]]></dc:creator><pubDate>Tue, 06 Jul 2010 21:20:21 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Tue, 06 Jul 2010 21:23:33 GMT]]></title><description><![CDATA[<p>Sorry kleine Korrektur.</p>
<p>Rand gibt nen int zurück, also</p>
<pre><code class="language-cpp">50+floor((double)rand()/RAND_MAX*50);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1922475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922475</guid><dc:creator><![CDATA[Max3000]]></dc:creator><pubDate>Tue, 06 Jul 2010 21:23:33 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Tue, 06 Jul 2010 21:32:32 GMT]]></title><description><![CDATA[<p>argh...</p>
<p>Nehm alles zurück...</p>
<p>Ist nicht mein Tag...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922478</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922478</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 06 Jul 2010 21:32:32 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Wed, 07 Jul 2010 10:18:47 GMT]]></title><description><![CDATA[<p>Hier eine kleine Funktion</p>
<pre><code class="language-cpp">int Random(int min,int max)
{
    return min+rand()%(max-min+1);
}
</code></pre>
<p>Habs nicht getestet, müsste aber so richtig sein.</p>
<p>MfG, Jochen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922630</guid><dc:creator><![CDATA[Jochen S.]]></dc:creator><pubDate>Wed, 07 Jul 2010 10:18:47 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Wed, 07 Jul 2010 10:33:40 GMT]]></title><description><![CDATA[<p>wenn man rand()%x rechnet, sollte man aber beachten das keine gleichmäßige Verteilung gegeben ist außer MAX_RAND%x == 0. Aber bei Spielen kann dies evtl. egal sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922635</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922635</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Wed, 07 Jul 2010 10:33:40 GMT</pubDate></item><item><title><![CDATA[Reply to Zufallszahl zwichen x und y on Wed, 07 Jul 2010 11:01:23 GMT]]></title><description><![CDATA[<p>Fellhuhn schrieb:</p>
<blockquote>
<p>wenn man rand()%x rechnet, sollte man aber beachten das keine gleichmäßige Verteilung gegeben ist außer MAX_RAND%x == 0. Aber bei Spielen kann dies evtl. egal sein.</p>
</blockquote>
<p>Auch bei praktisch allem anderen. Ich würde zwar nicht unbedingt die Lottozahlen damit ziehen (aus Angst vor Anwälten), aber beispielsweise zum professionellen wissenschaftlichen Rechnen benutzt man trotzdem die modulo-Methode, obwohl man dabei ansonsten ziemlich genau auf die Qualität der Zufallszahlen achtet. Einfach weil dieser Fehler extremst klein ist. Viel kleiner als sonstige Fehlerquellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922648</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 07 Jul 2010 11:01:23 GMT</pubDate></item></channel></rss>