<?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[Anfängerfrage]]></title><description><![CDATA[<p>Hallo,</p>
<p>in dem Buch &quot;Einstieg in C++&quot; von Arnold Willemer ist folgender Code. In dem Programm geht es darum, Zahlen der Größe nach zu sortieren. Das klappt auch, aber<br />
wenn es in dem Progra heisst &quot;Durchlauf beendet&quot;, steht immer &quot;4. Durchlauf beendet&quot;, auch wenn es &quot;1. Durchlauf...&quot; usw. heissen müsste.</p>
<p>Wa ist an dem Code also falsch?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;

const int MAX=5;

int main()
{   
    int feld[MAX], hilf;
    int i, j, k;

    srand(time(0)); //Zufallsgenerator vorbereiten
    for (i=0; i&lt;MAX; i++)
    {//Array besetzen und anzeigen
       feld [i] = rand() % 100 + 1;
       cout &lt;&lt; feld [i] &lt;&lt; &quot; &quot;;
    }
       cout &lt;&lt; endl;

       for(i=MAX-1; i&gt;0; i--) // MAX-1, weil die Karten immer mit dem rechten Nachbarn verglichen werden
       // d. h. nicht 4, sondern 3 Vergleiche
       {
           for(j=0; j&lt;i; j++)
           {
                    cout &lt;&lt; &quot;(&quot; &lt;&lt; j &lt;&lt; &quot;-&quot; &lt;&lt; j+1 &lt;&lt; &quot;):&quot; ;
                    if (feld[j]&gt;feld[j+1])
                    { // Tauschen erforderlich
                      hilf = feld[j];
                      feld[j] = feld[j+1];
                      feld[j+1] = hilf;
                      }
                      cout &lt;&lt; feld[j] &lt;&lt; &quot; - &quot; &lt;&lt; feld[j+1] &lt;&lt; &quot; &quot;;
                      }
                      // Zeige das Array in diesem Durchlauf
                      cout &lt;&lt; endl &lt;&lt; MAX-1 &lt;&lt; &quot;. Durchlauf beendet: &quot;;
                      for(k=0; k&lt;MAX; k++)
                      {    
                           cout &lt;&lt; feld[k] &lt;&lt; &quot; &quot;;
                      }
                      cout &lt;&lt; endl;

         }
     cin.clear();
     cin.get();
}
</code></pre>
<p>Liebe Grüße und vielen Dank schon mal <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/topic/314401/anfängerfrage</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 05:43:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314401.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Mar 2013 10:05:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:05:15 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>in dem Buch &quot;Einstieg in C++&quot; von Arnold Willemer ist folgender Code. In dem Programm geht es darum, Zahlen der Größe nach zu sortieren. Das klappt auch, aber<br />
wenn es in dem Progra heisst &quot;Durchlauf beendet&quot;, steht immer &quot;4. Durchlauf beendet&quot;, auch wenn es &quot;1. Durchlauf...&quot; usw. heissen müsste.</p>
<p>Wa ist an dem Code also falsch?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;

const int MAX=5;

int main()
{   
    int feld[MAX], hilf;
    int i, j, k;

    srand(time(0)); //Zufallsgenerator vorbereiten
    for (i=0; i&lt;MAX; i++)
    {//Array besetzen und anzeigen
       feld [i] = rand() % 100 + 1;
       cout &lt;&lt; feld [i] &lt;&lt; &quot; &quot;;
    }
       cout &lt;&lt; endl;

       for(i=MAX-1; i&gt;0; i--) // MAX-1, weil die Karten immer mit dem rechten Nachbarn verglichen werden
       // d. h. nicht 4, sondern 3 Vergleiche
       {
           for(j=0; j&lt;i; j++)
           {
                    cout &lt;&lt; &quot;(&quot; &lt;&lt; j &lt;&lt; &quot;-&quot; &lt;&lt; j+1 &lt;&lt; &quot;):&quot; ;
                    if (feld[j]&gt;feld[j+1])
                    { // Tauschen erforderlich
                      hilf = feld[j];
                      feld[j] = feld[j+1];
                      feld[j+1] = hilf;
                      }
                      cout &lt;&lt; feld[j] &lt;&lt; &quot; - &quot; &lt;&lt; feld[j+1] &lt;&lt; &quot; &quot;;
                      }
                      // Zeige das Array in diesem Durchlauf
                      cout &lt;&lt; endl &lt;&lt; MAX-1 &lt;&lt; &quot;. Durchlauf beendet: &quot;;
                      for(k=0; k&lt;MAX; k++)
                      {    
                           cout &lt;&lt; feld[k] &lt;&lt; &quot; &quot;;
                      }
                      cout &lt;&lt; endl;

         }
     cin.clear();
     cin.get();
}
</code></pre>
<p>Liebe Grüße und vielen Dank schon mal <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/2303217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303217</guid><dc:creator><![CDATA[Dietrich]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:05:15 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:10:12 GMT]]></title><description><![CDATA[<p>Zeile 35</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303221</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:10:12 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:15:41 GMT]]></title><description><![CDATA[<p>muss ich das ändern, damit es richtig läuft?</p>
<p>Schöne Grüße <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/2303222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303222</guid><dc:creator><![CDATA[Dietrich]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:15:41 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:17:40 GMT]]></title><description><![CDATA[<p>Ja.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303223</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:17:40 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:18:57 GMT]]></title><description><![CDATA[<p>Dietrich schrieb:</p>
<blockquote>
<p>muss ich das ändern, damit es richtig läuft?</p>
</blockquote>
<p>Wenn du nicht jedes mal das Ergebnis von 5-1 ausgeben möchtest ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303224</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:18:57 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:20:34 GMT]]></title><description><![CDATA[<p>... aber was mache ich da genau?</p>
<p><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/2303225</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303225</guid><dc:creator><![CDATA[Dietrich]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:20:34 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:21:52 GMT]]></title><description><![CDATA[<pre><code>cout &lt;&lt; endl &lt;&lt; i &lt;&lt; &quot;. Durchlauf beendet.&quot; &lt;&lt; endl;
</code></pre>
<p>Und vor allem das Buch beim lesen auch verstehen anstatt hier-rein-da-raus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303226</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:21:52 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 10:31:53 GMT]]></title><description><![CDATA[<p>...hast du nach deinen ersten drei Programmiertagen im Leben ganze Bücher vollständig verstanden?</p>
<p>Thx aber für die Antwort!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303228</guid><dc:creator><![CDATA[Dietrich]]></dc:creator><pubDate>Fri, 01 Mar 2013 10:31:53 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 11:15:20 GMT]]></title><description><![CDATA[<p>Nein, aber ich hab kleiner angefangen. Und nicht direkt mit einem Bubblesort.<br />
Aber auch dann wäre mir aufgefallen, dass dort eine neue Zeile ausgegeben wird, eine Konstante minus einen festen Wert und eine Zeichenkette, was dann letztlich zusammengesetzt ergibt: &quot;4.Durchlauf beendet.&quot;</p>
<p>Weil Ausgabe ist am Anfang jedes Tutorials und Buches drin.</p>
<p>Und wenn ich volkard mal (sinngemäß) zitieren darf:<br />
&quot;Ich finde deine Fehler nicht, weil ich irgendwie viel besser oder intelligenter bin, sondern weil ich denselben fehler schon 10mal selbst gemacht hab und ihn daher kenne.&quot; (Sowas nennt man dann aus Erfahrung lernen.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303247</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 11:15:20 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 11:55:57 GMT]]></title><description><![CDATA[<p>Dietrich schrieb:</p>
<blockquote>
<p>... aber was mache ich da genau?</p>
</blockquote>
<p>Keine Ahnung. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /> Jedenfalls nicht das, was man von einem lernenden Anfänger erwarten kann: selbst ausprobieren - verstehen - anwenden - oder ein Anfängerbuch lesen! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303264</guid><dc:creator><![CDATA[berniebutt]]></dc:creator><pubDate>Fri, 01 Mar 2013 11:55:57 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 12:43:40 GMT]]></title><description><![CDATA[<p>Ich glaube, die Leute meinen eigenrlich, Daß Du statt</p>
<pre><code>cout &lt;&lt; endl &lt;&lt; MAX-1 &lt;&lt; &quot;. Durchlauf beendet: &quot;;
</code></pre>
<p>lieber</p>
<pre><code>cout &lt;&lt; endl &lt;&lt; MAX-i &lt;&lt; &quot;. Durchlauf beendet: &quot;;
</code></pre>
<p>schreiben solltest.</p>
<p>Und konsequenter Einrücken wäre was.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

const int MAX=5;

int main()
{
    int feld[MAX], hilf;
    int i, j, k;

    srand(time(0)); //Zufallsgenerator vorbereiten
    for (i=0; i&lt;MAX; i++)
    {
        //Array besetzen und anzeigen
        feld [i] = rand() % 100 + 1;
        cout &lt;&lt; feld [i] &lt;&lt; &quot; &quot;;
    }
    cout &lt;&lt; endl;

    for(i=MAX-1; i&gt;0; i--) // MAX-1, weil die Karten immer mit dem rechten Nachbarn verglichen werden
        // d. h. nicht 4, sondern 3 Vergleiche
    {
        for(j=0; j&lt;i; j++)
        {
            cout &lt;&lt; &quot;(&quot; &lt;&lt; j &lt;&lt; &quot;-&quot; &lt;&lt; j+1 &lt;&lt; &quot;):&quot; ;
            if (feld[j]&gt;feld[j+1])
            {
                // Tauschen erforderlich
                hilf = feld[j];
                feld[j] = feld[j+1];
                feld[j+1] = hilf;
            }
            cout &lt;&lt; feld[j] &lt;&lt; &quot; - &quot; &lt;&lt; feld[j+1] &lt;&lt; &quot; &quot;;
        }
        // Zeige das Array in diesem Durchlauf
        cout &lt;&lt; endl &lt;&lt; MAX-i &lt;&lt; &quot;. Durchlauf beendet: &quot;;
        for(k=0; k&lt;MAX; k++)
        {
            cout &lt;&lt; feld[k] &lt;&lt; &quot; &quot;;
        }
        cout &lt;&lt; endl;

    }
    cin.clear();
    cin.get();
}
</code></pre>
<p>Das macht Deine IDE auch von selber.<br />
Microsoft: Strg+A gefolgt von Alt+F8<br />
CodeBlocks: Rechte Mauta &quot;Format using AStyle&quot;</p>
<p>Ist der Code im Buch auch so? Falls ja, wirf es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303288</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303288</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 01 Mar 2013 12:43:40 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:21:24 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Ich glaube, die Leute meinen eigenrlich, Daß Du statt</p>
<pre><code>cout &lt;&lt; endl &lt;&lt; MAX-1 &lt;&lt; &quot;. Durchlauf beendet: &quot;;
</code></pre>
<p>lieber</p>
<pre><code>cout &lt;&lt; endl &lt;&lt; MAX-i &lt;&lt; &quot;. Durchlauf beendet: &quot;;
</code></pre>
<p>schreiben solltest.</p>
<p>Und konsequenter Einrücken wäre was.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

const int MAX=5;

int main()
{
    int feld[MAX], hilf;
    int i, j, k;

    srand(time(0)); //Zufallsgenerator vorbereiten
    for (i=0; i&lt;MAX; i++)
    {
        //Array besetzen und anzeigen
        feld [i] = rand() % 100 + 1;
        cout &lt;&lt; feld [i] &lt;&lt; &quot; &quot;;
    }
    cout &lt;&lt; endl;

    for(i=MAX-1; i&gt;0; i--) // MAX-1, weil die Karten immer mit dem rechten Nachbarn verglichen werden
        // d. h. nicht 4, sondern 3 Vergleiche
    {
        for(j=0; j&lt;i; j++)
        {
            cout &lt;&lt; &quot;(&quot; &lt;&lt; j &lt;&lt; &quot;-&quot; &lt;&lt; j+1 &lt;&lt; &quot;):&quot; ;
            if (feld[j]&gt;feld[j+1])
            {
                // Tauschen erforderlich
                hilf = feld[j];
                feld[j] = feld[j+1];
                feld[j+1] = hilf;
            }
            cout &lt;&lt; feld[j] &lt;&lt; &quot; - &quot; &lt;&lt; feld[j+1] &lt;&lt; &quot; &quot;;
        }
        // Zeige das Array in diesem Durchlauf
        cout &lt;&lt; endl &lt;&lt; MAX-i &lt;&lt; &quot;. Durchlauf beendet: &quot;;
        for(k=0; k&lt;MAX; k++)
        {
            cout &lt;&lt; feld[k] &lt;&lt; &quot; &quot;;
        }
        cout &lt;&lt; endl;

    }
    cin.clear();
    cin.get();
}
</code></pre>
<p>Das macht Deine IDE auch von selber.<br />
Microsoft: Strg+A gefolgt von Alt+F8<br />
CodeBlocks: Rechte Mauta &quot;Format using AStyle&quot;</p>
<p>Ist der Code im Buch auch so? Falls ja, wirf es.</p>
</blockquote>
<p>so ist es aber auch falsch weil</p>
<pre><code>cout &lt;&lt; endl &lt;&lt; MAX-i &lt;&lt; &quot;. Durchlauf beendet: &quot;;
</code></pre>
<p>jetzt außerhalb der for schleife ist. hier würde auch nur immer wieder 4 ausgegeben werden oder vertu ich mich da jetzt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303306</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303306</guid><dc:creator><![CDATA[fakka270390]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:21:24 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:26:28 GMT]]></title><description><![CDATA[<p>Du hast 2 verschachtelte for-Schleifen.</p>
<p>Die äussere hat die Laufvariable i, die erste innere zählt mit j und die zweite innere mit k. Die Anweisung steht im Rumpf der äusseren Schleifen, d.h. dort i bekannt und wird pro Durchlauf auch geändert.</p>
<p>Du wirst also folgendes rausbekommen:</p>
<pre><code>// ......
5. Durchlauf beendet.
4. Durchlauf beendet.
3. Durchlauf beendet.
2. Durchlauf beendet.
1. Durchlauf beendet.
</code></pre>
<p>Mit meinem Vorschalg zählt er genau umgekehrt, also von 1 (oder 0) hoch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303310</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303310</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:26:28 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:31:05 GMT]]></title><description><![CDATA[<p>ups okay hab eine klammer übersehn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303311</guid><dc:creator><![CDATA[fakka270390]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:31:05 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:31:08 GMT]]></title><description><![CDATA[<p>Wie ich eben sagte, das gilt ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303312</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:31:08 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Thu, 12 Jun 2014 03:14:39 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303313</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303313</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 12 Jun 2014 03:14:39 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:46:56 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

const int MAX=5;
 int feld[MAX], hilf, i;

void zufallszahlen()
{
     srand(time(0)); //Zufallsgenerator vorbereiten
    for (i=0; i&lt;MAX; i++)
    {
        //Array besetzen und anzeigen
        feld [i] = rand() % 100 + 1;
        cout &lt;&lt; feld [i] &lt;&lt; &quot; &quot;;
    }
}

void tauschen()
{

        for(int j=0; j&lt;i; j++)
        {
            cout &lt;&lt; &quot;(&quot; &lt;&lt; j &lt;&lt; &quot;-&quot; &lt;&lt; j+1 &lt;&lt; &quot;):&quot; ;
            if (feld[j]&gt;feld[j+1])
            {
                // Tauschen erforderlich
                hilf = feld[j];
                feld[j] = feld[j+1];
                feld[j+1] = hilf;
            }
            cout &lt;&lt; feld[j] &lt;&lt; &quot; - &quot; &lt;&lt; feld[j+1] &lt;&lt; &quot; &quot;;
        }
}

void ergebnis()
{
    // Zeige das Array in diesem Durchlauf
        cout &lt;&lt; endl &lt;&lt; MAX-i &lt;&lt; &quot;. Durchlauf beendet: &quot;;
        for(int k=0; k&lt;MAX; k++)
        {
            cout &lt;&lt; feld[k] &lt;&lt; &quot; &quot;;
        }
        cout &lt;&lt; endl;
}
void bubblesort()
{
    zufallszahlen();

    cout &lt;&lt; endl;

    for(i=MAX-1; i&gt;0; i--) // MAX-1, weil die Karten immer mit dem rechten Nachbarn verglichen werden
        // d. h. nicht 4, sondern 3 Vergleiche
    {
        tauschen();
        ergebnis();

    }
    cin.clear();
    cin.get();
}

int main()
{

    bubblesort();

}
</code></pre>
<p>so sieht das ganze doch schon viel schöner aus find ich zumindest^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303318</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303318</guid><dc:creator><![CDATA[fakka270390]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:46:56 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:54:00 GMT]]></title><description><![CDATA[<p>Komischen Geschmack hast du.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303324</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303324</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:54:00 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:55:48 GMT]]></title><description><![CDATA[<p>Ist halt die Frage, ob man als Kind beim Versteckspielen bis 20 gezählt hat oder von 20 auf 0 runtergezählt hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303325</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:55:48 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:57:42 GMT]]></title><description><![CDATA[<p>Jockelx schrieb:</p>
<blockquote>
<p>Komischen Geschmack hast du.</p>
</blockquote>
<p>ich find das so übersichtlicher weil man nich mehr so viele schleifen ineinander verschachtelt hat und mit den klammern nich mehr durcheinander kommt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303329</guid><dc:creator><![CDATA[fakka270390]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:57:42 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 13:58:41 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
using namespace std;

const int MAX=5;//Unfug
int feld[MAX], hilf, i;//Pöse!

void zufallszahlen()//ok, aber ohne globale Variablen
{
     srand(time(0)); //Zufallsgenerator vorbereiten//hier falsch
    for (i=0; i&lt;MAX; i++)
    {
        //Array besetzen und anzeigen
        feld [i] = rand() % 100 + 1;
        cout &lt;&lt; feld [i] &lt;&lt; &quot; &quot;;//hier bitte keine Ausgabe
    }
}

void tauschen()//ah, eine innere Schleife, an sich ok
{//Ausgabe wegmachen

        for(int j=0; j&lt;i; j++)
        {
            cout &lt;&lt; &quot;(&quot; &lt;&lt; j &lt;&lt; &quot;-&quot; &lt;&lt; j+1 &lt;&lt; &quot;):&quot; ;
            if (feld[j]&gt;feld[j+1])
            {
                // Tauschen erforderlich
                hilf = feld[j];
                feld[j] = feld[j+1];
                feld[j+1] = hilf;
            }
            cout &lt;&lt; feld[j] &lt;&lt; &quot; - &quot; &lt;&lt; feld[j+1] &lt;&lt; &quot; &quot;;
        }
}

void ergebnis()//Ja, so kann man ausgeben
{
    // Zeige das Array in diesem Durchlauf
        cout &lt;&lt; endl &lt;&lt; MAX-i &lt;&lt; &quot;. Durchlauf beendet: &quot;;//weg
        for(int k=0; k&lt;MAX; k++)
        {
            cout &lt;&lt; feld[k] &lt;&lt; &quot; &quot;;
        }
        cout &lt;&lt; endl;
}
void bubblesort()//nu wirds aber kindisch, viel zu überladen, das ist die main. 
{
    zufallszahlen();

    cout &lt;&lt; endl;

    for(i=MAX-1; i&gt;0; i--) // MAX-1, weil die Karten immer mit dem rechten Nachbarn verglichen werden
        // d. h. nicht 4, sondern 3 Vergleiche
    {
        tauschen();
        ergebnis();

    }
    cin.clear();
    cin.get();
}

int main()
{

    bubblesort();

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2303330</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303330</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:58:41 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 14:02:28 GMT]]></title><description><![CDATA[<p>Die Kritik war sicherlich nicht das aufteilen in Funktionen...<br />
Aber ein globales i und hilf (feld am besten auch nicht)?<br />
Eine Sortierfunktion, sollte sicherlich ein Feld sortieren und nicht erstmal ein Neues erzeugen!<br />
Funktionen machen etwas. Ein Substantiv (zufallszahlen) als Funktionsname ist nicht schön.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303334</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Fri, 01 Mar 2013 14:02:28 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 14:44:52 GMT]]></title><description><![CDATA[<p>bin ja auch noch n ziemlicher grünschnabel was c++ angeht. die ganzen konventionen sind mir noch nicht so geläufig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303344</guid><dc:creator><![CDATA[fakka270390]]></dc:creator><pubDate>Fri, 01 Mar 2013 14:44:52 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerfrage on Fri, 01 Mar 2013 14:45:36 GMT]]></title><description><![CDATA[<p>Durch Klammern sollte man sich nicht durcheinanderbringen lassen können.</p>
<p>Dass man Teile in Funktionen auslagert ist auch gut.</p>
<p>Aber deine Formatierung ist Müll und deine globalen Variablen auch...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303345</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 14:45:36 GMT</pubDate></item></channel></rss>