<?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[verständnisfrage array]]></title><description><![CDATA[<p>hallo, wieso wird beidem folgenden code</p>
<pre><code>#include &lt;iostream&gt;

using namespace std;

int main(){

	int x[] = {16 , 31 , 8 , 11 , 64 , 3 , 26 , 45 , 32 , 13};

	bool off = true;
	int n = 10 , i;

	for ( i = 0; i&lt;=(n-1); i++){

			if (x[i] % 2 == 1 ){

if (off)
x[i] = 0 ;
else
x[i] = 1 ;
off = !off;
			}
cout &lt;&lt; x [i] &lt;&lt; endl ;
	}
return 0 ;
}
</code></pre>
<p>diese ausgabe erzeugt?</p>
<p>16<br />
0<br />
8<br />
1<br />
64<br />
0<br />
26<br />
1<br />
32<br />
0</p>
<p>ich versteh nicht, woran es liegt, dass manchmal die 0 und manchmal die 1 kommt :S</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/234269/verständnisfrage-array</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 11:55:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/234269.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 15 Feb 2009 18:38:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to verständnisfrage array on Sun, 15 Feb 2009 18:38:29 GMT]]></title><description><![CDATA[<p>hallo, wieso wird beidem folgenden code</p>
<pre><code>#include &lt;iostream&gt;

using namespace std;

int main(){

	int x[] = {16 , 31 , 8 , 11 , 64 , 3 , 26 , 45 , 32 , 13};

	bool off = true;
	int n = 10 , i;

	for ( i = 0; i&lt;=(n-1); i++){

			if (x[i] % 2 == 1 ){

if (off)
x[i] = 0 ;
else
x[i] = 1 ;
off = !off;
			}
cout &lt;&lt; x [i] &lt;&lt; endl ;
	}
return 0 ;
}
</code></pre>
<p>diese ausgabe erzeugt?</p>
<p>16<br />
0<br />
8<br />
1<br />
64<br />
0<br />
26<br />
1<br />
32<br />
0</p>
<p>ich versteh nicht, woran es liegt, dass manchmal die 0 und manchmal die 1 kommt :S</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664371</guid><dc:creator><![CDATA[Maddin K.]]></dc:creator><pubDate>Sun, 15 Feb 2009 18:38:29 GMT</pubDate></item><item><title><![CDATA[Reply to verständnisfrage array on Sun, 15 Feb 2009 18:49:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

int main(){

    int x[] = {16 , 31 , 8 , 11 , 64 , 3 , 26 , 45 , 32 , 13};

    bool off = true;
    int n = 10 , i;

    // Schleife geht alle 10 Arrayelemente durch
    for ( i = 0; i &lt;= (n-1); i++){
        // Wenn der Wert des Elements ungerade ist (also eine Divison durch 2
        // einen Rest von 1 ergibt), dann weise dem Element einen neuen
        // Wert (0 oder 1) zu
        if (x[i] % 2 == 1 ) {
            // Ist 'off' true wird dem Element der Wert 0 zugewiesen
            if (off)
                x[i] = 0;
            // sonst wird dem Element der Wert 1 zugewiesen
            else
                x[i] = 1;
            // &quot;Ändere&quot; 'off' von true auf false oder von false auf true ;)
            off = !off;
        }
        // Ausgabe des Elements
        cout &lt;&lt; x [i] &lt;&lt; endl ;
    }
return 0 ;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1664376</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664376</guid><dc:creator><![CDATA[Mizar]]></dc:creator><pubDate>Sun, 15 Feb 2009 18:49:38 GMT</pubDate></item><item><title><![CDATA[Reply to verständnisfrage array on Sun, 15 Feb 2009 19:07:54 GMT]]></title><description><![CDATA[<p>okay danke! das off = !off wars also <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/1664392</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664392</guid><dc:creator><![CDATA[Maddin K.]]></dc:creator><pubDate>Sun, 15 Feb 2009 19:07:54 GMT</pubDate></item></channel></rss>