<?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[do while mit mehreren Bedingungen]]></title><description><![CDATA[<p>Ist es möglich eine do while Schleife so in der art zu gestalten?</p>
<pre><code>do{
//Code
}while(s_hp!=0 || g_hp!=0);
</code></pre>
<p>Weil so geht es nicht und ich bräuchte soetwas.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/324525/do-while-mit-mehreren-bedingungen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Jul 2026 08:41:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/324525.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Mar 2014 16:25:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:25:00 GMT]]></title><description><![CDATA[<p>Ist es möglich eine do while Schleife so in der art zu gestalten?</p>
<pre><code>do{
//Code
}while(s_hp!=0 || g_hp!=0);
</code></pre>
<p>Weil so geht es nicht und ich bräuchte soetwas.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2389981</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389981</guid><dc:creator><![CDATA[Skeptar]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:25:00 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:26:41 GMT]]></title><description><![CDATA[<p>doch, so geht es. diese != und || sind schlussendlich auch nur operatoren...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2389982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389982</guid><dc:creator><![CDATA[Fytch]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:26:41 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:27:18 GMT]]></title><description><![CDATA[<p>So geht es.<br />
Es wird ausgeführt so lange s_hp nicht 0 ist ODER g_hp nicht 0 ist.<br />
Du suchst vermutlich und, nicht oder.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2389983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389983</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:27:18 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:37:25 GMT]]></title><description><![CDATA[<p>Nein...<br />
Ich möchte es abgebrochen haben wenn s_hp = 0 <strong>oder</strong> g_hp = 0.<br />
Aber ich denke ihr braucht Code, weil ich habe ausprobiert und es klappt nicht.</p>
<p>Einmal die Funktion kampf</p>
<pre><code>void kampf(string s_name, string s_pokemon, string g_name, string g_pokemon){
    int s_hp=100, g_hp=100, schaden=0;
    do{
        system(&quot;cls&quot;);
        s_lebensbalken(s_name, s_pokemon, s_hp);
        g_lebensbalken(g_name, g_pokemon, g_hp);

        cout &lt;&lt; &quot;\n\n\n&quot; &lt;&lt; s_name &lt;&lt; &quot; bitte den Schaden von &quot; &lt;&lt; s_pokemon &lt;&lt; &quot; eingeben: &quot;;
        cin &gt;&gt; schaden;
        g_hp=g_hp-schaden;

        if(g_hp&lt;0){
            g_hp=0;
        }
        else if(s_hp&lt;0){
            s_hp=0;
        }
        else{
        }
    }while(s_hp!=0 || g_hp!=0);
}
</code></pre>
<p>Und die Funktion g_lebensbalken (s_lebenbalken ist genauso aufgebaut)</p>
<pre><code>void g_lebensbalken(string g_name, string g_pokemon, int &amp;g_hp){
    if(g_hp &lt;= 0){
        g_hp=0;
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|          |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp
             &lt;&lt; &quot;\n\n\n&quot; &lt;&lt; g_name &lt;&lt; &quot; faellt in Ohnmacht.&quot;;
    }
    else if(g_hp &lt; 10){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|-         |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 20){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|--        |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 30){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|---       |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 40){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|----      |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 50){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|-----     |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 60){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|------    |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 70){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|-------   |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 80){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|--------  |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 90){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|--------- |\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &lt; 100){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|----------|\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp == 100){
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|----------|\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
    else if(g_hp &gt; 100){
        g_hp=100;
        cout &lt;&lt; &quot;\n\n\nName: &quot; &lt;&lt; g_name &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;|----------|\n&quot;
             &lt;&lt; &quot;Pokemon: &quot; &lt;&lt; g_pokemon &lt;&lt; &quot;\n&quot;
             &lt;&lt; &quot;HP: &quot; &lt;&lt; g_hp;
    }
}
</code></pre>
<p>Ich hoffe damit könnt ihr was anfangen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
(Und falls ihr bockt habt schreibt mir als feedback ob ich etwas an meinem &quot;Stil&quot; verbessern kann)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2389986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389986</guid><dc:creator><![CDATA[Skeptar]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:37:25 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:39:49 GMT]]></title><description><![CDATA[<p>Nein, du möchtest und.<br />
Ich selbst habe es, merk ich gerade, ungünstig formuliert:</p>
<blockquote>
<p>Es wird ausgeführt so lange (s_hp nicht 0 ist ODER g_hp nicht 0) == true ist.</p>
</blockquote>
<p>Das heißt:<br />
Wenn s_hp 0 und g_hp 1 -&gt; false || true -&gt; true<br />
Wenn s_hp 1 und g_hp 0 -&gt; true || false -&gt; true<br />
...<br />
Du suchst und.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2389990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389990</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:39:49 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:40:35 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Du suchst vermutlich und, nicht oder.</p>
</blockquote>
<p>Skeptar schrieb:</p>
<blockquote>
<p>Nein...<br />
Ich möchte es abgebrochen haben wenn s_hp = 0 <strong>oder</strong> g_hp = 0.</p>
</blockquote>
<p>Doch!</p>
<p>Du negierst deine Bedingung</p>
<pre><code>while (!(s_hp==0 || g_hp==0));
</code></pre>
<p>Du kannst auch das ! in die Klammer ziehen. Aber dann wird auch das || zum &amp;&amp;</p>
<pre><code>while (s_hp!=0 &amp;&amp; g_hp!=0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2389991</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389991</guid><dc:creator><![CDATA[DirkB]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:40:35 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:42:34 GMT]]></title><description><![CDATA[<p>Skeptar schrieb:</p>
<blockquote>
<p>Nein...<br />
Ich möchte es abgebrochen haben wenn s_hp = 0 <strong>oder</strong> g_hp = 0.<br />
Aber ich denke ihr braucht Code, weil ich habe ausprobiert und es klappt nicht.</p>
</blockquote>
<p>wie nein? du widersprichst dir selbst. du sagst:<br />
<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mover accent="true"><mrow><mo>(</mo><msub><mi>s</mi><mrow><mi>h</mi><mi>p</mi></mrow></msub><mo>=</mo><mn>0</mn><mo>)</mo><mo>∨</mo><mo>(</mo><msub><mi>g</mi><mrow><mi>h</mi><mi>p</mi></mrow></msub><mo>=</mo><mn>0</mn><mo>)</mo></mrow><mo stretchy="true">‾</mo></mover></mrow><annotation encoding="application/x-tex">\overline{(s_{hp}= 0)\vee (g_{hp}= 0)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.9500000000000001em;"></span><span class="strut bottom" style="height:1.236108em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="overline mord"><span class="vlist"><span style="top:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:1em;">​</span></span><span class="mord textstyle cramped"><span class="mopen">(</span><span class="mord"><span class="mord mathit">s</span><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle cramped"><span class="mord scriptstyle cramped"><span class="mord mathit">h</span><span class="mord mathit">p</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span><span class="mrel">=</span><span class="mord mathrm">0</span><span class="mclose">)</span><span class="mbin">∨</span><span class="mopen">(</span><span class="mord"><span class="mord mathit" style="margin-right:0.03588em;">g</span><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.03588em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle cramped"><span class="mord scriptstyle cramped"><span class="mord mathit">h</span><span class="mord mathit">p</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span><span class="mrel">=</span><span class="mord mathrm">0</span><span class="mclose">)</span></span></span><span style="top:-0.87em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:1em;">​</span></span><span class="reset-textstyle textstyle uncramped overline-line"></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:1em;">​</span></span>​</span></span></span></span></span></span><br />
-&gt; <a href="http://de.wikipedia.org/wiki/De_Morgansche_Gesetze" rel="nofollow">http://de.wikipedia.org/wiki/De_Morgansche_Gesetze</a><br />
<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mo>(</mo><msub><mi>s</mi><mrow><mi>h</mi><mi>p</mi></mrow></msub><mo>≠</mo><mn>0</mn><mo>)</mo><mo>∧</mo><mo>(</mo><msub><mi>g</mi><mrow><mi>h</mi><mi>p</mi></mrow></msub><mo>≠</mo><mn>0</mn><mo>)</mo></mrow><annotation encoding="application/x-tex">(s_{hp}\neq 0)\wedge (g_{hp}\neq 0)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1.036108em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="mopen">(</span><span class="mord"><span class="mord mathit">s</span><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle cramped"><span class="mord scriptstyle cramped"><span class="mord mathit">h</span><span class="mord mathit">p</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span><span class="mrel">≠</span><span class="mord mathrm">0</span><span class="mclose">)</span><span class="mbin">∧</span><span class="mopen">(</span><span class="mord"><span class="mord mathit" style="margin-right:0.03588em;">g</span><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.03588em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle cramped"><span class="mord scriptstyle cramped"><span class="mord mathit">h</span><span class="mord mathit">p</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span><span class="mrel">≠</span><span class="mord mathrm">0</span><span class="mclose">)</span></span></span></span></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2389993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389993</guid><dc:creator><![CDATA[Fytch]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:42:34 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 16:55:49 GMT]]></title><description><![CDATA[<p>Ja ihr habt recht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Sorry und danke! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2389997</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2389997</guid><dc:creator><![CDATA[Skeptar]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:55:49 GMT</pubDate></item><item><title><![CDATA[Reply to do while mit mehreren Bedingungen on Thu, 20 Mar 2014 17:33:15 GMT]]></title><description><![CDATA[<p>Skeptar schrieb:</p>
<blockquote>
<p>(Und falls ihr bockt habt schreibt mir als feedback ob ich etwas an meinem &quot;Stil&quot; verbessern kann)</p>
</blockquote>
<p>Ja: wenn Du 2 mal das gleiche machst: Schreib eine Funktion!<br />
Und schau Dir die Standardbibliothek an. Z.B. die Methoden von <code>std::string</code> - unten z.B. benutze ich einen praktischen Konstruktor.<br />
Mach Dir nicht zuviel Arbeit mit Formatierung in der Konsole - dafür gibt es Bibliotheken, die das besser können.</p>
<p>Hier mal eine kuerzere Version von <code>lebensbalken()</code> . Da fehlt noch ein wenig was (kleiner 0, größer 100 usw.), aber die Idee kommt rüber, hoffe ich.</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;

struct pokemon{
  int hp;
};

std::string lebensbalken(const pokemon&amp; p){
  const int len=p.hp/10;
  return std::string{&quot;|&quot;} + std::string(len, '-') + std::string(10-len, ' ') + std::string{&quot;|&quot;};
}

int main(){
  pokemon pikachu{100}, gesundheit{65};
  std::cout &lt;&lt; lebensbalken(pikachu) &lt;&lt; '\n'
	    &lt;&lt; lebensbalken(gesundheit) &lt;&lt; '\n';
}
</code></pre>
<p>Gruß,<br />
FW</p>
<p>Nach Diktat Bierchen trinken gegangen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2390005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2390005</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Thu, 20 Mar 2014 17:33:15 GMT</pubDate></item></channel></rss>