<?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[Zufällige zahlen]]></title><description><![CDATA[<p>Schreibe ein Programm das zufällig zahlen ausgeben soll. Nun will ich das die Zahlen zwischen null und hundert liegen sollen. Dafür habe es so gemacht wie es auf der Seite von <a href="http://cplusplus.com" rel="nofollow">cplusplus.com</a> empfohlen wurde, doch es klappt irgendwie nicht.</p>
<pre><code>( value % 100 ) is in the range 0 to 99
( value % 100 + 1 ) is in the range 1 to 100
( value % 30 + 1985 ) is in the range 1985 to 2014
</code></pre>
<p><a href="http://www.cplusplus.com/reference/clibrary/cstdlib/rand/" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstdlib/rand/</a></p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &quot;std_lib_facilities.h&quot;
#include &lt;time.h&gt;
#include &lt;stdio.h&gt;

void randint(){
	 rand() % 100;
	 cout &lt;&lt; rand() &lt;&lt; endl;
}

int main()
{
	cout &lt;&lt; &quot;Please enter a char to generate a number\n&quot;;
	cout &lt;&lt; &quot;To exit enter \&quot;!\&quot;\n&quot;;
    char c;
	while(cin &gt;&gt; c){
	if ('!' == c){
		break;
	}
	else
		randint();
	}

    keep_window_open();
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/279286/zufällige-zahlen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 16:22:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/279286.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Dec 2010 19:20:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zufällige zahlen on Wed, 22 Dec 2010 19:20:04 GMT]]></title><description><![CDATA[<p>Schreibe ein Programm das zufällig zahlen ausgeben soll. Nun will ich das die Zahlen zwischen null und hundert liegen sollen. Dafür habe es so gemacht wie es auf der Seite von <a href="http://cplusplus.com" rel="nofollow">cplusplus.com</a> empfohlen wurde, doch es klappt irgendwie nicht.</p>
<pre><code>( value % 100 ) is in the range 0 to 99
( value % 100 + 1 ) is in the range 1 to 100
( value % 30 + 1985 ) is in the range 1985 to 2014
</code></pre>
<p><a href="http://www.cplusplus.com/reference/clibrary/cstdlib/rand/" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstdlib/rand/</a></p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &quot;std_lib_facilities.h&quot;
#include &lt;time.h&gt;
#include &lt;stdio.h&gt;

void randint(){
	 rand() % 100;
	 cout &lt;&lt; rand() &lt;&lt; endl;
}

int main()
{
	cout &lt;&lt; &quot;Please enter a char to generate a number\n&quot;;
	cout &lt;&lt; &quot;To exit enter \&quot;!\&quot;\n&quot;;
    char c;
	while(cin &gt;&gt; c){
	if ('!' == c){
		break;
	}
	else
		randint();
	}

    keep_window_open();
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1998047</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998047</guid><dc:creator><![CDATA[winux]]></dc:creator><pubDate>Wed, 22 Dec 2010 19:20:04 GMT</pubDate></item><item><title><![CDATA[Reply to Zufällige zahlen on Wed, 22 Dec 2010 19:25:00 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void randint(){
     rand() % 100;     // Berechne eine Zufallszahl aus [0,99]
     cout &lt;&lt; rand() &lt;&lt; endl; // Gib irgendeine andere Zufallszahl aus
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1998049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998049</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 22 Dec 2010 19:25:00 GMT</pubDate></item><item><title><![CDATA[Reply to Zufällige zahlen on Wed, 22 Dec 2010 19:27:13 GMT]]></title><description><![CDATA[<p>Fehlt da nicht srand(time(NULL)); ?<br />
Sonst kommt da ja jedes mal das gleiche</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998050</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998050</guid><dc:creator><![CDATA[Conflict]]></dc:creator><pubDate>Wed, 22 Dec 2010 19:27:13 GMT</pubDate></item><item><title><![CDATA[Reply to Zufällige zahlen on Wed, 22 Dec 2010 19:27:18 GMT]]></title><description><![CDATA[<p>Jetzt ist alles klar, da war der Fehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998051</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998051</guid><dc:creator><![CDATA[winux]]></dc:creator><pubDate>Wed, 22 Dec 2010 19:27:18 GMT</pubDate></item><item><title><![CDATA[Reply to Zufällige zahlen on Wed, 22 Dec 2010 19:31:25 GMT]]></title><description><![CDATA[<p>Conflict schrieb:</p>
<blockquote>
<p>Fehlt da nicht srand(time(NULL)); ?<br />
Sonst kommt da ja jedes mal das gleiche</p>
</blockquote>
<p>Wo?<br />
Habe es gefunden.<br />
Das Problem ist gelöst. Danke für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998052</guid><dc:creator><![CDATA[winux]]></dc:creator><pubDate>Wed, 22 Dec 2010 19:31:25 GMT</pubDate></item><item><title><![CDATA[Reply to Zufällige zahlen on Wed, 22 Dec 2010 19:32:26 GMT]]></title><description><![CDATA[<p>Conflict bezieht sich hier darauf, dass zwei unabhängige Programmdurchläufe dieselbe Sequenz an Zufallszahlen produzieren würde. rand erzeugt nicht wirklich zufällige Zahlen, sondern berechnet aus der letzten Zufallszahl sozusagen die nächste. Daher sollte man dafür sorgen, dass die erste wenigstens einigermaßen zufällig ist. Mit srand gibt man diesen &quot;Anfangswert&quot; an und kann dafür wie Conflict es gezeigt hat, zum Beispiel die Zeit hernehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998053</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 22 Dec 2010 19:32:26 GMT</pubDate></item><item><title><![CDATA[Reply to Zufällige zahlen on Wed, 22 Dec 2010 19:34:12 GMT]]></title><description><![CDATA[<p>Alles klar, jetzt Funktioniert alles und die Zahlen sind zufällig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998055</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998055</guid><dc:creator><![CDATA[winux]]></dc:creator><pubDate>Wed, 22 Dec 2010 19:34:12 GMT</pubDate></item></channel></rss>