<?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[Bubble Sort mit Array funktioniert nicht]]></title><description><![CDATA[<p>Hallo und guten Tag,</p>
<p>da dies mein Erster Beitrag ist würde ich mich gerne erst einmal vorstellen.<br />
Mein Name ist Michael und ich versuche mich seit ca. 2 Wochen an C++.</p>
<p>Nun habe ich jedoch ein Problem bei dem ich selbst nach stundenlanger Suche keine Lösung finden will.</p>
<p>Und zwar will ich durch Bubble Sort float Werte nach Größe sortieren, jedem float wert aber 2 String Arrays zuordnen.</p>
<p>Die float Werte sind ebenfalls in einem Array.</p>
<p>Es sollte letztendlich eine Rangliste (nach Größe) der Werte entstehen.</p>
<p>Leider schaffe ich es nicht einmal, nur das float Array zu sortieren.</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox57205" checked="true" /><label for="checkbox57205">aus 5 Wiederholungen einer for Schleife.</label></div></p>
<p>Dies sieht bei mir so aus:</p>
<pre><code>void bubble_sort ()

 {

  for (int x = 0; i &lt; 5; ++x)

    for (float j = 0; j &lt; 5 - x - 1; ++j)

      if (werte[j] &gt; werte[j + 1])

     {

        int temp = werte[j];

        werte[j] = werte[j + 1];

        werte[j + 1] = temp;

      }

  }
</code></pre>
<p>Leider will es bei mir einfach nicht funktonieren.</p>
<p>Ich wäre sehr erfreut wenn mir jemand weiterhelfen könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/335541/bubble-sort-mit-array-funktioniert-nicht</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 18:18:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/335541.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Nov 2015 15:11:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bubble Sort mit Array funktioniert nicht on Wed, 25 Nov 2015 15:11:09 GMT]]></title><description><![CDATA[<p>Hallo und guten Tag,</p>
<p>da dies mein Erster Beitrag ist würde ich mich gerne erst einmal vorstellen.<br />
Mein Name ist Michael und ich versuche mich seit ca. 2 Wochen an C++.</p>
<p>Nun habe ich jedoch ein Problem bei dem ich selbst nach stundenlanger Suche keine Lösung finden will.</p>
<p>Und zwar will ich durch Bubble Sort float Werte nach Größe sortieren, jedem float wert aber 2 String Arrays zuordnen.</p>
<p>Die float Werte sind ebenfalls in einem Array.</p>
<p>Es sollte letztendlich eine Rangliste (nach Größe) der Werte entstehen.</p>
<p>Leider schaffe ich es nicht einmal, nur das float Array zu sortieren.</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox57205" checked="true" /><label for="checkbox57205">aus 5 Wiederholungen einer for Schleife.</label></div></p>
<p>Dies sieht bei mir so aus:</p>
<pre><code>void bubble_sort ()

 {

  for (int x = 0; i &lt; 5; ++x)

    for (float j = 0; j &lt; 5 - x - 1; ++j)

      if (werte[j] &gt; werte[j + 1])

     {

        int temp = werte[j];

        werte[j] = werte[j + 1];

        werte[j + 1] = temp;

      }

  }
</code></pre>
<p>Leider will es bei mir einfach nicht funktonieren.</p>
<p>Ich wäre sehr erfreut wenn mir jemand weiterhelfen könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477067</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477067</guid><dc:creator><![CDATA[MüderJoe]]></dc:creator><pubDate>Wed, 25 Nov 2015 15:11:09 GMT</pubDate></item><item><title><![CDATA[Reply to Bubble Sort mit Array funktioniert nicht on Wed, 25 Nov 2015 15:16:23 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>was soll dieser i und x Mix in der ersten Schleife?<br />
Warum ist j ein float?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477068</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477068</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Wed, 25 Nov 2015 15:16:23 GMT</pubDate></item><item><title><![CDATA[Reply to Bubble Sort mit Array funktioniert nicht on Wed, 25 Nov 2015 16:24:49 GMT]]></title><description><![CDATA[<p>Oh man, das ist fast schon peinlich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
<p>Habe ich wohl übersehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477073</guid><dc:creator><![CDATA[MüderJoe]]></dc:creator><pubDate>Wed, 25 Nov 2015 16:24:49 GMT</pubDate></item><item><title><![CDATA[Reply to Bubble Sort mit Array funktioniert nicht on Wed, 25 Nov 2015 23:11:08 GMT]]></title><description><![CDATA[<p>Jockelx schrieb:</p>
<blockquote>
<p>Warum ist j ein float?</p>
</blockquote>
<p>Was mich zu der Frage führt (@TO): Hast du überhaupt mal versucht den Code zu compilieren? Das mit dem float als Arrayindex frisst der Compiler nämlich nicht und werte ist nicht definiert (oder weiter oben global?).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477116</guid><dc:creator><![CDATA[döööööööner]]></dc:creator><pubDate>Wed, 25 Nov 2015 23:11:08 GMT</pubDate></item><item><title><![CDATA[Reply to Bubble Sort mit Array funktioniert nicht on Thu, 26 Nov 2015 09:33:52 GMT]]></title><description><![CDATA[<p>döööööööner schrieb:</p>
<blockquote>
<p>Das mit dem float als Arrayindex frisst der Compiler nämlich nicht</p>
</blockquote>
<p>? Klar kompiliert das, musst dich u.U. lediglich damit abfinden, dass aus deiner Zählschleife eine Endlosschleife wird.</p>
<p>döööööööner schrieb:</p>
<blockquote>
<p>oder weiter oben global?</p>
</blockquote>
<p>Aber hallo. Und <code>i</code> sicherlich auch. Zwecks Recycling, für die Umwelt und so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477148</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477148</guid><dc:creator><![CDATA[qaw]]></dc:creator><pubDate>Thu, 26 Nov 2015 09:33:52 GMT</pubDate></item><item><title><![CDATA[Reply to Bubble Sort mit Array funktioniert nicht on Thu, 26 Nov 2015 12:24:04 GMT]]></title><description><![CDATA[<p>qaw schrieb:</p>
<blockquote>
<p>döööööööner schrieb:</p>
<blockquote>
<p>Das mit dem float als Arrayindex frisst der Compiler nämlich nicht</p>
</blockquote>
<p>? Klar kompiliert das, musst dich u.U. lediglich damit abfinden, dass aus deiner Zählschleife eine Endlosschleife wird.</p>
</blockquote>
<p>Das musst du mir zeigen...</p>
<pre><code>&gt;type bubble.c
int werte[42]; //fehlt, ohne stoppt der Compiler zu früh...

void bubble_sort ()

 {

  for (int x = 0; i &lt; 5; ++x)

    for (float j = 0; j &lt; 5 - x - 1; ++j)

      if (werte[j] &gt; werte[j + 1])

     {

        int temp = werte[j];

        werte[j] = werte[j + 1];

        werte[j + 1] = temp;

      }

  }

&gt;gcc -std=c99 -Wall bubble.c
bubble.c: In function 'bubble_sort':
bubble.c:7:19: error: 'i' undeclared (first use in this function)
bubble.c:7:19: note: each undeclared identifier is reported only once for each function it appears in
bubble.c:11:16: error: array subscript is not an integer
bubble.c:11:27: error: array subscript is not an integer
bubble.c:15:25: error: array subscript is not an integer
bubble.c:17:14: error: array subscript is not an integer
bubble.c:17:25: error: array subscript is not an integer
bubble.c:19:14: error: array subscript is not an integer

&gt;gcc --version
gcc (GCC) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2477165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477165</guid><dc:creator><![CDATA[döööööööner]]></dc:creator><pubDate>Thu, 26 Nov 2015 12:24:04 GMT</pubDate></item></channel></rss>