<?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 mit While (Break und continue)]]></title><description><![CDATA[<p>Hallo,<br />
hab wieder ne Frage -.- Bitte helfen...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

int main()
{
unsigned short small;
unsigned long large;
unsigned long skip;
unsigned long target;
const unsigned short MAXSMALL=65535;

cout &lt;&lt; &quot;Bitte eine kleine Zahl eingeben: &quot;;
cin &gt;&gt; small;
cout &lt;&lt; &quot;Bitte eine grosse Zahl eingeben: &quot;;
cin &gt;&gt; large;
cout &lt;&lt; &quot;Bitte eine Sprungzahl eingeben: &quot;;
cin &gt;&gt; skip;
cout &lt;&lt; &quot;Bitte eine Zielzahl eingeben: &quot;;
cin &gt;&gt; target;
cout &lt;&lt; &quot;\n&quot;;

while (small &lt; large &amp;&amp; large &gt; 0 &amp;&amp; small &lt; MAXSMALL)

{

small++;

if (small % skip == 0) // (1)
{
cout &lt;&lt; &quot;Ueberspringen &quot; &lt;&lt; small &lt;&lt; endl; // (2)
continue;
}

if (large == target) 
{
cout &lt;&lt; &quot;Ziel getroffen!&quot;;
break;
}
large-=2; // (3)
}

cout &lt;&lt; &quot;\nKlein: &quot; &lt;&lt; small &lt;&lt; &quot; Gross: &quot; &lt;&lt; large &lt;&lt; endl;
system(&quot;PAUSE&quot;);
return 0;

}
</code></pre>
<p>Kommentare:<br />
(1) - Wenn ich 2,20,4,6 eingebe, dann ist ja 2 Mod 4 = 2 und nicht 0, wie wird dann If aber true?<br />
(2) - und wenn small 2 ist, wie kann es sein, dass small als 4 ausgegeben wird, wo es doch eig 2 ist?<br />
(3) - kann das nicht gleich nach small++ auftreten?</p>
<p>DANKE FÜR JEDE ANTWORT !</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/266710/problem-mit-while-break-und-continue</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 00:46:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/266710.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 May 2010 21:54:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit While (Break und continue) on Wed, 12 May 2010 21:54:01 GMT]]></title><description><![CDATA[<p>Hallo,<br />
hab wieder ne Frage -.- Bitte helfen...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

int main()
{
unsigned short small;
unsigned long large;
unsigned long skip;
unsigned long target;
const unsigned short MAXSMALL=65535;

cout &lt;&lt; &quot;Bitte eine kleine Zahl eingeben: &quot;;
cin &gt;&gt; small;
cout &lt;&lt; &quot;Bitte eine grosse Zahl eingeben: &quot;;
cin &gt;&gt; large;
cout &lt;&lt; &quot;Bitte eine Sprungzahl eingeben: &quot;;
cin &gt;&gt; skip;
cout &lt;&lt; &quot;Bitte eine Zielzahl eingeben: &quot;;
cin &gt;&gt; target;
cout &lt;&lt; &quot;\n&quot;;

while (small &lt; large &amp;&amp; large &gt; 0 &amp;&amp; small &lt; MAXSMALL)

{

small++;

if (small % skip == 0) // (1)
{
cout &lt;&lt; &quot;Ueberspringen &quot; &lt;&lt; small &lt;&lt; endl; // (2)
continue;
}

if (large == target) 
{
cout &lt;&lt; &quot;Ziel getroffen!&quot;;
break;
}
large-=2; // (3)
}

cout &lt;&lt; &quot;\nKlein: &quot; &lt;&lt; small &lt;&lt; &quot; Gross: &quot; &lt;&lt; large &lt;&lt; endl;
system(&quot;PAUSE&quot;);
return 0;

}
</code></pre>
<p>Kommentare:<br />
(1) - Wenn ich 2,20,4,6 eingebe, dann ist ja 2 Mod 4 = 2 und nicht 0, wie wird dann If aber true?<br />
(2) - und wenn small 2 ist, wie kann es sein, dass small als 4 ausgegeben wird, wo es doch eig 2 ist?<br />
(3) - kann das nicht gleich nach small++ auftreten?</p>
<p>DANKE FÜR JEDE ANTWORT !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1896484</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1896484</guid><dc:creator><![CDATA[KompiPauer]]></dc:creator><pubDate>Wed, 12 May 2010 21:54:01 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit While (Break und continue) on Wed, 12 May 2010 23:14:01 GMT]]></title><description><![CDATA[<p>Wieso bist du mit dem Debugger nicht einfach zeilenweise durchgegangen?<br />
Dann hättest du sofort gesehen, dass die Bedingung im ersten Durchgang nicht wahr ist, sehr wohl aber im zweiten Durchgang, wo small 4 wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1896505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1896505</guid><dc:creator><![CDATA[Athar]]></dc:creator><pubDate>Wed, 12 May 2010 23:14:01 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit While (Break und continue) on Thu, 13 May 2010 09:28:27 GMT]]></title><description><![CDATA[<p>Athar schrieb:</p>
<blockquote>
<p>Wieso bist du mit dem Debugger nicht einfach zeilenweise durchgegangen?<br />
Dann hättest du sofort gesehen, dass die Bedingung im ersten Durchgang nicht wahr ist, sehr wohl aber im zweiten Durchgang, wo small 4 wird.</p>
</blockquote>
<p>Das ist mir neu. Wo kann man denn sehen, wo die Vorgänge vom Debuggen protokoliert werden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1896554</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1896554</guid><dc:creator><![CDATA[KompiPauer]]></dc:creator><pubDate>Thu, 13 May 2010 09:28:27 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit While (Break und continue) on Thu, 13 May 2010 09:48:42 GMT]]></title><description><![CDATA[<p>du gehst mit dem Debugger schrittweise durch das Programm und schaust dir die Werte an bzw. in welche Zweige das Programm springt. Wie du den Debugger benutzt fragst du am Besten im IDE/ Compiler-Forum nach.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1896563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1896563</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 13 May 2010 09:48:42 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit While (Break und continue) on Thu, 13 May 2010 13:51:11 GMT]]></title><description><![CDATA[<p>Danke, hab das Problem gelöst <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title="=)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1896679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1896679</guid><dc:creator><![CDATA[KompiPauer]]></dc:creator><pubDate>Thu, 13 May 2010 13:51:11 GMT</pubDate></item></channel></rss>