<?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[Problem: Ineinander verschaltete schleifen]]></title><description><![CDATA[<p>Und wieder eine Anfängerfrage...</p>
<p>Ich wollte ein Beispielprogramm aus einem Buch so modifizieren, dass er zwei beenden- bzw. fortsetzenoptionen anbietet. Ich baue aber leider nur Mist.<br />
Hier ein Versuch.</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;ctime&gt;

using namespace std;

int main()
{
    //randomizer
    srand(time(0));
    int dieZahl = rand() %100 +1; 
    //randomizer END

    int versuche = 0, guess;
    char wahl = 'j';

    cout &lt;&lt; &quot;Tja, tipp ne Zahl ein, die der Rechner vorbestimmt hat.&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Oder, wenn du das nicht spielen willst, tipp einfach 'n' ein.&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Wenn doch, tipp 'j' ein.\n&quot; &lt;&lt; endl;
    cin &gt;&gt; wahl;

    while (wahl == 'j');
    {

        do
        {
         cin &gt;&gt; guess;
         ++versuche;

         if (guess &gt; dieZahl)
         cout &lt;&lt; &quot;\nZu hoch, versuchs nomma.\n&quot; &lt;&lt; endl;

         if (guess &lt; dieZahl)
         cout &lt;&lt; &quot;\nZu niedrig, versuchs nomma.\n&quot; &lt;&lt; endl;  

        }
         while (guess != dieZahl);
         cout &lt;&lt; &quot;\nRichtig! du hast es in &quot; &lt;&lt; versuche &lt;&lt; &quot; Versuchen geschafft.\n&quot; &lt;&lt; endl;         
         cout &lt;&lt; &quot;Willst du wieder spielen? j/n&quot; &lt;&lt; endl;

    }

    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
<p>Danke im Vorraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/235077/problem-ineinander-verschaltete-schleifen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 07:10:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/235077.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Feb 2009 12:09:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem: Ineinander verschaltete schleifen on Wed, 25 Feb 2009 12:09:50 GMT]]></title><description><![CDATA[<p>Und wieder eine Anfängerfrage...</p>
<p>Ich wollte ein Beispielprogramm aus einem Buch so modifizieren, dass er zwei beenden- bzw. fortsetzenoptionen anbietet. Ich baue aber leider nur Mist.<br />
Hier ein Versuch.</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;ctime&gt;

using namespace std;

int main()
{
    //randomizer
    srand(time(0));
    int dieZahl = rand() %100 +1; 
    //randomizer END

    int versuche = 0, guess;
    char wahl = 'j';

    cout &lt;&lt; &quot;Tja, tipp ne Zahl ein, die der Rechner vorbestimmt hat.&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Oder, wenn du das nicht spielen willst, tipp einfach 'n' ein.&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Wenn doch, tipp 'j' ein.\n&quot; &lt;&lt; endl;
    cin &gt;&gt; wahl;

    while (wahl == 'j');
    {

        do
        {
         cin &gt;&gt; guess;
         ++versuche;

         if (guess &gt; dieZahl)
         cout &lt;&lt; &quot;\nZu hoch, versuchs nomma.\n&quot; &lt;&lt; endl;

         if (guess &lt; dieZahl)
         cout &lt;&lt; &quot;\nZu niedrig, versuchs nomma.\n&quot; &lt;&lt; endl;  

        }
         while (guess != dieZahl);
         cout &lt;&lt; &quot;\nRichtig! du hast es in &quot; &lt;&lt; versuche &lt;&lt; &quot; Versuchen geschafft.\n&quot; &lt;&lt; endl;         
         cout &lt;&lt; &quot;Willst du wieder spielen? j/n&quot; &lt;&lt; endl;

    }

    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
<p>Danke im Vorraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1669921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1669921</guid><dc:creator><![CDATA[nuttshell]]></dc:creator><pubDate>Wed, 25 Feb 2009 12:09:50 GMT</pubDate></item><item><title><![CDATA[Reply to Problem: Ineinander verschaltete schleifen on Wed, 25 Feb 2009 12:45:03 GMT]]></title><description><![CDATA[<p>1. Was ist das Problem?<br />
2. Ist es nicht sinnlos immer wieder dieselbe Zahl raten zu lassen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1669943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1669943</guid><dc:creator><![CDATA[Hundeman]]></dc:creator><pubDate>Wed, 25 Feb 2009 12:45:03 GMT</pubDate></item><item><title><![CDATA[Reply to Problem: Ineinander verschaltete schleifen on Wed, 25 Feb 2009 15:34:38 GMT]]></title><description><![CDATA[<p>Alles in Ordnung, ich habs geschafft.</p>
<p>Hier nochmal das Endergebniss:</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;ctime&gt;

using namespace std;

int main()
{
    //randomizer
    srand(time(0));
    int dieZahl = rand() %100 +1; 
    //randomizer END

    int versuche = 0, guess;
    char wahl = 'j';
    char wahl1 = 'j';

    cout &lt;&lt; &quot;Tja, tipp ne Zahl ein, die der Rechner vorbestimmt hat.&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Oder, wenn du das nicht spielen willst, tipp einfach 'n' ein.&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Wenn doch, tipp 'j' ein.\n&quot; &lt;&lt; endl;
    cin &gt;&gt; wahl;

    if (wahl == 'j')
       {
       do //äussere Schleife Anfang
       {
        do  //innere Schleife IO
        {
         cout &lt;&lt; &quot;OK, dann rate mal.&quot; &lt;&lt; endl;
         cin &gt;&gt; guess;
         ++versuche;

         if (guess &gt; dieZahl)
         cout &lt;&lt; &quot;\nZu hoch, versuchs nomma.\n&quot; &lt;&lt; endl;

         if (guess &lt; dieZahl)
         cout &lt;&lt; &quot;\nZu niedrig, versuchs nomma.\n&quot; &lt;&lt; endl;  

        }
         while (guess != dieZahl);  //innere Schleife END
         cout &lt;&lt; &quot;\nRichtig! du hast es in &quot; &lt;&lt; versuche &lt;&lt; &quot; Versuchen geschafft.\n&quot; &lt;&lt; endl;         
         cout &lt;&lt; &quot;Willst du wieder spielen? j/n&quot; &lt;&lt; endl; 
         cin &gt;&gt; wahl1;
        }
         while (wahl1 != 'n'); //äussere Schleife ENDE

     }
    else 

    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1670107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1670107</guid><dc:creator><![CDATA[nuttshell]]></dc:creator><pubDate>Wed, 25 Feb 2009 15:34:38 GMT</pubDate></item></channel></rss>