<?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[Eigener Sortieralgorythmus]]></title><description><![CDATA[<p>Hy<br />
Ich habe ein Problem mit dem Programmieren meines eigenen Sortieralgorythmus<br />
Wir sollten uns als Hausaufgabe einen eigenen Sort ausdenken und nun programieren, doch nun habe ich mehrere Probleme bei der Umsetzung, da ich sowieso noch ein Anfänger bin.</p>
<p>Mein Sortieralgorythmus lautet:<br />
Wir sollen 10 Zahlen in einem Feld sortieren<br />
Vergleiche immer benachbarte Zahlen miteinander.z.B Zahl1 mit Zahl2 wenn Zahl &gt; Zahl2 tauschen wenn nicht stehen lassen. Ende falls ein Durchlauf ohne Tausch stattgefunden hat.Anschließende Ausgabe in eine ListBox.</p>
<p>Die Anfänge meines Programmes:</p>
<p>void __fastcall TForm1::Button2Click(TObject <em>Sender)<br />
{<br />
ListBox1-&gt;Clear();<br />
int</em>zahlenfeld = new int[11];<br />
zahlenfeld[1] = StrToInt(Form1-&gt;Edit1-&gt;Text);<br />
zahlenfeld[2] = StrToInt(Form1-&gt;Edit2-&gt;Text);<br />
zahlenfeld[3] = StrToInt(Form1-&gt;Edit3-&gt;Text);<br />
zahlenfeld[4] = StrToInt(Form1-&gt;Edit4-&gt;Text);<br />
zahlenfeld[5] = StrToInt(Form1-&gt;Edit5-&gt;Text);<br />
zahlenfeld[6] = StrToInt(Form1-&gt;Edit6-&gt;Text);<br />
zahlenfeld[7] = StrToInt(Form1-&gt;Edit7-&gt;Text);<br />
zahlenfeld[8] = StrToInt(Form1-&gt;Edit8-&gt;Text);<br />
zahlenfeld[9] = StrToInt(Form1-&gt;Edit9-&gt;Text);<br />
zahlenfeld[10] = StrToInt(Form1-&gt;Edit10-&gt;Text);<br />
int x = 0;</p>
<p>for (int y=1;y+1&gt;y ; )</p>
<p>und ab da weiß ich nicht mehr weiter!!</p>
<p>Vielen Dank schon mal im Voraus für eure Bemühungen <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/181787/eigener-sortieralgorythmus</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 11:59:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/181787.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 May 2007 12:37:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 12:44:50 GMT]]></title><description><![CDATA[<p>Hy<br />
Ich habe ein Problem mit dem Programmieren meines eigenen Sortieralgorythmus<br />
Wir sollten uns als Hausaufgabe einen eigenen Sort ausdenken und nun programieren, doch nun habe ich mehrere Probleme bei der Umsetzung, da ich sowieso noch ein Anfänger bin.</p>
<p>Mein Sortieralgorythmus lautet:<br />
Wir sollen 10 Zahlen in einem Feld sortieren<br />
Vergleiche immer benachbarte Zahlen miteinander.z.B Zahl1 mit Zahl2 wenn Zahl &gt; Zahl2 tauschen wenn nicht stehen lassen. Ende falls ein Durchlauf ohne Tausch stattgefunden hat.Anschließende Ausgabe in eine ListBox.</p>
<p>Die Anfänge meines Programmes:</p>
<p>void __fastcall TForm1::Button2Click(TObject <em>Sender)<br />
{<br />
ListBox1-&gt;Clear();<br />
int</em>zahlenfeld = new int[11];<br />
zahlenfeld[1] = StrToInt(Form1-&gt;Edit1-&gt;Text);<br />
zahlenfeld[2] = StrToInt(Form1-&gt;Edit2-&gt;Text);<br />
zahlenfeld[3] = StrToInt(Form1-&gt;Edit3-&gt;Text);<br />
zahlenfeld[4] = StrToInt(Form1-&gt;Edit4-&gt;Text);<br />
zahlenfeld[5] = StrToInt(Form1-&gt;Edit5-&gt;Text);<br />
zahlenfeld[6] = StrToInt(Form1-&gt;Edit6-&gt;Text);<br />
zahlenfeld[7] = StrToInt(Form1-&gt;Edit7-&gt;Text);<br />
zahlenfeld[8] = StrToInt(Form1-&gt;Edit8-&gt;Text);<br />
zahlenfeld[9] = StrToInt(Form1-&gt;Edit9-&gt;Text);<br />
zahlenfeld[10] = StrToInt(Form1-&gt;Edit10-&gt;Text);<br />
int x = 0;</p>
<p>for (int y=1;y+1&gt;y ; )</p>
<p>und ab da weiß ich nicht mehr weiter!!</p>
<p>Vielen Dank schon mal im Voraus für eure Bemühungen <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/1286754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286754</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 12:44:50 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 12:49:05 GMT]]></title><description><![CDATA[<p><a href="http://de.wikipedia.org/wiki/Bubblesort#Formaler_Algorithmus" rel="nofollow">http://de.wikipedia.org/wiki/Bubblesort#Formaler_Algorithmus</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286764</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286764</guid><dc:creator><![CDATA[siehe]]></dc:creator><pubDate>Thu, 17 May 2007 12:49:05 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 14:54:33 GMT]]></title><description><![CDATA[<p>bin ich aufn kopf gefallen oder ist das die falsche abteilung -.- ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286839</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286839</guid><dc:creator><![CDATA[Stelfer]]></dc:creator><pubDate>Thu, 17 May 2007 14:54:33 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 16:38:39 GMT]]></title><description><![CDATA[<p>hast du ein problem oder kannst du mir helfen? <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=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286903</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286903</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 16:38:39 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 17:06:10 GMT]]></title><description><![CDATA[<p>so in etwa wäre eine mögliche bubblesort Implementierung ...<br />
... <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="🙂"
    /> und das macht das was du willst ... sollte es zumindest ... hab es aber nicht getestet ^^</p>
<p><strong>edit</strong><br />
Wegen Ignoranz des Thread-Erstellers Lösung gelöscht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286907</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Thu, 17 May 2007 17:06:10 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 16:50:32 GMT]]></title><description><![CDATA[<p>Vielleicht solltest du redo bei Gelegenheit mal wieder auf false setzen. Sonst terminiert's nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286908</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286908</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Thu, 17 May 2007 16:50:32 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 16:52:54 GMT]]></title><description><![CDATA[<p>wir sollen das ohne bubble sort machen ich muss einfach nur wissen wie ich mein programm weiter schreiben muss damit das das macht was ich will.</p>
<p>for (int y=1;y+1&gt;y;)<br />
{</p>
<p>wie muss ich die schleife weiter schreiben<br />
und wie setzt ich die Abruchbedingung in C++ um<br />
also wenn kein tausch mehr stattgefunden hat zahlen in listbox ausgeben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286911</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 16:52:54 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 16:53:44 GMT]]></title><description><![CDATA[<p>Jester schrieb:</p>
<blockquote>
<p>Vielleicht solltest du redo bei Gelegenheit mal wieder auf false setzen. Sonst terminiert's nicht.</p>
</blockquote>
<p>ich hab keine Ahnung was du damit meinst ich bin ein blutiger anfänger</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286912</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286912</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 16:53:44 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 17:05:37 GMT]]></title><description><![CDATA[<p>Hmm jetzt mal ganz im ernst. Du bist mehr als faul und dreist! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /><br />
Das was euer Lehrer will ist nichts anderes als der BubbleSort Algorithmus. Ich hab dir jetzt sogar eine komplette Implementierung gegeben. Ließ einfach mal die Links die du bekommst ... dann fällt dir sowas auf!</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/324">@Jester</a>: Ja sorry ... hab es zu spät gesehen und hab es noch angefügt ... hab halt wie gesagt nicht getestet ... wie nie wenn ich was poste <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="😃"
    /> Nja is auch egal ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286917</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Thu, 17 May 2007 17:05:37 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 17:46:17 GMT]]></title><description><![CDATA[<p>^^sorry <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="😞"
    /> aber trotzdem Danke<br />
könntest du deine lösung nochmal reinstellen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286929</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 17:46:17 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 18:29:42 GMT]]></title><description><![CDATA[<p>Ich habs nochmal probiert:</p>
<p>void __fastcall TForm1::Button2Click(TObject <em>Sender)<br />
{<br />
ListBox1-&gt;Clear();<br />
int</em>zahlenfeld = new int[11];<br />
zahlenfeld[1] = StrToInt(Form1-&gt;Edit1-&gt;Text);<br />
zahlenfeld[2] = StrToInt(Form1-&gt;Edit2-&gt;Text);<br />
zahlenfeld[3] = StrToInt(Form1-&gt;Edit3-&gt;Text);<br />
zahlenfeld[4] = StrToInt(Form1-&gt;Edit4-&gt;Text);<br />
zahlenfeld[5] = StrToInt(Form1-&gt;Edit5-&gt;Text);<br />
zahlenfeld[6] = StrToInt(Form1-&gt;Edit6-&gt;Text);<br />
zahlenfeld[7] = StrToInt(Form1-&gt;Edit7-&gt;Text);<br />
zahlenfeld[8] = StrToInt(Form1-&gt;Edit8-&gt;Text);<br />
zahlenfeld[9] = StrToInt(Form1-&gt;Edit9-&gt;Text);<br />
zahlenfeld[10] = StrToInt(Form1-&gt;Edit10-&gt;Text);</p>
<p>for<br />
{<br />
(if 11[y]&gt; 11[y+1]);<br />
( 11[y], 11[y+1]);</p>
<p>}while 11[y]&lt; 11[y+1];<br />
{<br />
ListBox1-&gt;Items-&gt;Add(IntToStr(zahlenfeld));<br />
}<br />
//---------------------------------------------------------------------------</p>
<p>aber läuft halt immernoch nicht leider</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286963</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286963</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 18:29:42 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:16:37 GMT]]></title><description><![CDATA[<p>Aicde schrieb:</p>
<blockquote>
<pre><code class="language-cpp">(if 11[y]&gt; 11[y+1]);
    (   11[y], 11[y+1]);
</code></pre>
</blockquote>
<p><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=":confused:"
      alt="😕"
    /> was soll denn des 11[y]?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286985</guid><dc:creator><![CDATA[kaffee]]></dc:creator><pubDate>Thu, 17 May 2007 19:16:37 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:31:10 GMT]]></title><description><![CDATA[<p>weiß ich auch nicht wie gesagt anfänger<br />
ich hab versucht das von wikipedia auf seite 1 umzusetzen<br />
nach dem ich aufgefodert wurde die links zu lesen die ich bekomme <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/1286989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286989</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 19:31:10 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:36:31 GMT]]></title><description><![CDATA[<p>Aicde schrieb:</p>
<blockquote>
<p>weiß ich auch nicht wie gesagt anfänger<br />
ich hab versucht das von wikipedia auf seite 1 umzusetzen<br />
nach dem ich aufgefodert wurde die links zu lesen die ich bekomme <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>
</blockquote>
<p>Guter Link muss ich auch mal lesen!!<br />
Ich denke das sollte eher zahlenfeld[y] heißen oder?<br />
Edit: nehms mir nicht übel aber ich würd dir empfehlen mal ein gutes Tutorial durchzumachen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286992</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286992</guid><dc:creator><![CDATA[kaffee]]></dc:creator><pubDate>Thu, 17 May 2007 19:36:31 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:38:28 GMT]]></title><description><![CDATA[<p>Auszug aus Wikipedia</p>
<p>Der Algorithmus sieht im Pseudocode so aus:</p>
<p>prozedur bubbleSort( A : Liste sortierbarer Elemente ) definiert als:<br />
n := Länge( A ) - 1<br />
wiederhole<br />
vertauscht := falsch<br />
für jedes i in 0 bis n wiederhole:<br />
falls A[ i ] &gt; A[ i + 1 ] dann<br />
vertausche( A[ i ], A[ i + 1 ] )<br />
vertauscht := wahr<br />
falls ende<br />
für ende<br />
n := n - 1<br />
während vertauscht<br />
prozedur ende</p>
<p>ich kann damit nicht wirklich viel anfangen ich brauch mal jemand der mir c++ komplet erklärt besonders die umsetzung insbesodere Felder also arees und schleifen <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/1286995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286995</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 19:38:28 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:45:04 GMT]]></title><description><![CDATA[<p><a href="http://tutorial.schornboeck.net/hello_world.htm" rel="nofollow">http://tutorial.schornboeck.net/hello_world.htm</a><br />
hier ein Tutorial</p>
<p>Edit: Schleifen: <a href="http://tutorial.schornboeck.net/schleifen.htm" rel="nofollow">http://tutorial.schornboeck.net/schleifen.htm</a><br />
Arrays: <a href="http://tutorial.schornboeck.net/arrays.htm" rel="nofollow">http://tutorial.schornboeck.net/arrays.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1286996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1286996</guid><dc:creator><![CDATA[kaffee]]></dc:creator><pubDate>Thu, 17 May 2007 19:45:04 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:44:29 GMT]]></title><description><![CDATA[<p>Naja ich geb dir nochmal die Funktion ... ist allerdings in diesem Fall ne Template-Func ... also setz stattdessen einfach den entsprechenden Typ ein falls dein Compiler damit nicht klar kommt<br />
...</p>
<pre><code class="language-cpp">template &lt;typename T&gt;
void bubble_sort(T*&amp; arr, const std::size_t&amp; size)
{
	bool redo = false;
	do {
		redo = false;
		for (std::size_t i = 0; (i &lt; (size - 1) &amp;&amp; arr[i] != NULL &amp;&amp; arr[i+1] != NULL); ++i)
			if (arr[i] &gt; arr[i + 1])		{ std::swap&lt;T&gt;(arr[i], arr[i + 1]); redo = true; }
	} while (redo == true);	
}
</code></pre>
<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287002</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Thu, 17 May 2007 19:44:29 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:50:24 GMT]]></title><description><![CDATA[<p>großes Dankeschön<br />
ich werd mich mal dransetzen und morgen hochladen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287007</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Thu, 17 May 2007 19:50:24 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 19:57:50 GMT]]></title><description><![CDATA[<p>Hmm ich erklär ihn dir mal sicherheitshalber <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">template &lt;typename T&gt;
void bubble_sort(T*&amp; arr, const std::size_t&amp; size) // also übergeben wird eine Referenz eines Zeigers auf einen Array vom Type T ... die Größe des Arrays (Anzahl Elemente) gibt size an.
{
    bool redo = false; // Speichert ob wir nochmal durchlaufen müssen.
    do {
        redo = false; // Setzt am Anfang jedes Laufes redo wieder auf false zurück, da wir sonnst eine Endlosschleife hätten.
        for (std::size_t i = 0; i &lt; (size - 1); ++i) // wir gehen alle Elemente des Arrays durch ...
            if (arr[i] &gt; arr[i + 1])  // wenn das Element größer ist als das  folgende Element ...      
            { 
                std::swap&lt;T&gt;(arr[i], arr[i + 1]); // ... müssen wir die einmal austauschen ... =&gt; arr[i] = arr[i+1] &amp;&amp; arr[i + 1] = arr[i] 
                redo = true; // Es war noch nicht alles richtig sortiert also müssen wir nochmal durchlaufen ...
            }
    } while (redo == true);   // erst aufhören wenn in der ganzen for-Schleife nie die Bedingung der if-Abfrage wahr war.
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1287016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287016</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Thu, 17 May 2007 19:57:50 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Thu, 17 May 2007 20:18:17 GMT]]></title><description><![CDATA[<p>Ein einfacher Algo wäre Insertion Sort: (im Pseudocode)</p>
<pre><code>Zahl key, Indizes i,j
Feld A

für j=2,...,n{
  key=A[j];
  i=j-1;
  solange i&gt;0 und A[i]&gt;key {
     A[i+1]=A[i];
     i=i-1;
  }
  A[i+1]=key;
}
</code></pre>
<p>Dabei werden immer die direkten Nachbarn verglichen und das Vergleichselement ggf. nach links verschoben.</p>
<p>Bsp.:</p>
<pre><code>A[1]   A[2]   A[3]   A[4]   A[5]    A[6]
 5  &lt;-&gt; 2      4      6      1       3
 2      5  &lt;-&gt; 4      6      1       3
 2      4      5     &gt;6&lt;     1       3
 2  -&gt;  4  -&gt;  5 -&gt;   6 -&gt;   1       3
 |-------------------------- |
 1      2      4  -&gt;  5  -&gt;  6   -&gt;  3
               |---------------------|
 1      2      3      4      5       6
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1287023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287023</guid><dc:creator><![CDATA[Kuldren]]></dc:creator><pubDate>Thu, 17 May 2007 20:18:17 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Fri, 18 May 2007 11:38:21 GMT]]></title><description><![CDATA[<p>Ich habs fast fertig aber irgendwo ist noch ein fehler!!!</p>
<p>void __fastcall TForm1::Button2Click(TObject <em>Sender)<br />
{<br />
ListBox1-&gt;Clear();<br />
int</em> zahlenfeld = new int[11];<br />
zahlenfeld[1] = StrToInt(Form1-&gt;Edit1-&gt;Text);<br />
zahlenfeld[2] = StrToInt(Form1-&gt;Edit2-&gt;Text);<br />
zahlenfeld[3] = StrToInt(Form1-&gt;Edit3-&gt;Text);<br />
zahlenfeld[4] = StrToInt(Form1-&gt;Edit4-&gt;Text);<br />
zahlenfeld[5] = StrToInt(Form1-&gt;Edit5-&gt;Text);<br />
zahlenfeld[6] = StrToInt(Form1-&gt;Edit6-&gt;Text);<br />
zahlenfeld[7] = StrToInt(Form1-&gt;Edit7-&gt;Text);<br />
zahlenfeld[8] = StrToInt(Form1-&gt;Edit8-&gt;Text);<br />
zahlenfeld[9] = StrToInt(Form1-&gt;Edit9-&gt;Text);<br />
zahlenfeld[10] = StrToInt(Form1-&gt;Edit10-&gt;Text);<br />
}</p>
<p>template &lt;typename y&gt;<br />
void eigener_sortieralgorithmus(y*&amp; zahlenfeld, const std::size_t&amp; size)<br />
{<br />
bool redo = false;<br />
do {<br />
redo = false;<br />
for (std::size_t i = 0; i &lt; (size - 1); ++i)<br />
if (zahlenfeld[i] &gt; zahlenfeld[i + 1])<br />
{<br />
std::swap&lt;y&gt;(zahlenfeld[i], zahlenfeld[i + 1]);<br />
redo = true;<br />
}<br />
} while (redo == true); }</p>
<p>{<br />
ListBox1-&gt;Items-&gt;Add(IntToStr(zahlenfeld [i]));<br />
}</p>
<p>//---------------------------------------------------------------------------</p>
<p>C++ Fehler Deklarationn nicht ordnungsgemäß abgeschlossen <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=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287334</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Fri, 18 May 2007 11:38:21 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Fri, 18 May 2007 11:43:07 GMT]]></title><description><![CDATA[<p>was ist eigentlich ein template??????</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287336</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Fri, 18 May 2007 11:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Fri, 18 May 2007 11:45:26 GMT]]></title><description><![CDATA[<p>Aicde schrieb:</p>
<blockquote>
<p>Ich habs fast fertig aber irgendwo ist noch ein fehler!!!</p>
<pre><code class="language-cpp">void __fastcall TForm1::Button2Click(TObject *Sender)
{
  ListBox1-&gt;Clear();
  int* zahlenfeld = new int[11];
  zahlenfeld[1] = StrToInt(Form1-&gt;Edit1-&gt;Text);
  zahlenfeld[2] = StrToInt(Form1-&gt;Edit2-&gt;Text);
  zahlenfeld[3] = StrToInt(Form1-&gt;Edit3-&gt;Text);
  zahlenfeld[4] = StrToInt(Form1-&gt;Edit4-&gt;Text);
  zahlenfeld[5] = StrToInt(Form1-&gt;Edit5-&gt;Text);
  zahlenfeld[6] = StrToInt(Form1-&gt;Edit6-&gt;Text);
  zahlenfeld[7] = StrToInt(Form1-&gt;Edit7-&gt;Text);
  zahlenfeld[8] = StrToInt(Form1-&gt;Edit8-&gt;Text);
  zahlenfeld[9] = StrToInt(Form1-&gt;Edit9-&gt;Text);
  zahlenfeld[10] = StrToInt(Form1-&gt;Edit10-&gt;Text);
}

template &lt;typename y&gt;
void eigener_sortieralgorithmus(y*&amp; zahlenfeld, const std::size_t&amp; size) 
{
  bool redo = false; 
  do { 
    redo = false;
    for (std::size_t i = 0; i &lt; (size - 1); ++i)
      if (zahlenfeld[i] &gt; zahlenfeld[i + 1])  
      { 
        std::swap&lt;y&gt;(zahlenfeld[i], zahlenfeld[i + 1]); 
        redo = true;           
      } 
   } while (redo == true);
}

{
  ListBox1-&gt;Items-&gt;Add(IntToStr(zahlenfeld [i]));
}

//---------------------------------------------------------------------------
</code></pre>
</blockquote>
<p>Nulltens: sfds</p>
<p>Erstens: Steht der letzte Abschnitt wirklich so einsam in deiner Datei? Wenn ja, da fehlt der Funktionskopf zu diesem Rumpf.</p>
<p>Zweitens: Wo rufst du die Sortierfunktion denn auf? Und mit welchen Parametern? (in der OnButton-Methode werden die Zahlen ab Index 1 eingetragen, die Sortierfunktion beginnt mit Index 0 zu sortieren)</p>
<p>Drittens: Warum selber schreiben? std::sort() ist doch schon verfügbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287339</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 18 May 2007 11:45:26 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Fri, 18 May 2007 11:52:01 GMT]]></title><description><![CDATA[<p>zu Drittens: weil Hausaufgabe</p>
<p>zu Erstens: ja!! also muss da noch Ausgabe hin oder so was ähnliches</p>
<p>zu zweitens: also muss zwischen zeile 16-17 irgend ein aufruf????</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287341</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Fri, 18 May 2007 11:52:01 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Fri, 18 May 2007 12:02:19 GMT]]></title><description><![CDATA[<p>Aicde schrieb:</p>
<blockquote>
<p>zu Erstens: ja!! also muss da noch Ausgabe hin oder so was ähnliches</p>
</blockquote>
<p>Ich weiß ja nicht, was du vorhast, aber auf jeden Fall muß dieser Code-Abschnitt in einer Funktion landen (eventuell sogar ans Ende der Button2Click()).</p>
<blockquote>
<p>zu zweitens: also muss zwischen zeile 16-17 irgend ein aufruf????</p>
</blockquote>
<p>Zwischen die Zeilen nicht (das wäre ja wieder außerhalb einer Funktion ;)), aber hinter Zeile 14 solltest du schon die Sortierfunktion aufrufen.</p>
<p>PS: Ein Template ist eine Art Schablone für viele verschiedene Funktionen. Das heißt, anstatt je eine Sortierfunktion für int's, double's, string's oder hundekuchen zu schreiben, schreibst du eine Schablone für beliebige Typen (der Bezeichner 'y' ist übrigens etwas unüblich) und lässt dir vom Compiler genau die Variante(n) erzeugen, die du brauchst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287349</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 18 May 2007 12:02:19 GMT</pubDate></item><item><title><![CDATA[Reply to Eigener Sortieralgorythmus on Fri, 18 May 2007 12:48:14 GMT]]></title><description><![CDATA[<p>Ich hatte das bei allen meinen programmen unten stehen z.B. bei der ausgabe von Pirmzahlen</p>
<p>[quote=&quot;CStoll&quot;]</p>
<p>Aicde schrieb:</p>
<blockquote>
<p>zu Erstens: ja!! also muss da noch Ausgabe hin oder so was ähnliches</p>
</blockquote>
<p>Ich weiß ja nicht, was du vorhast, aber auf jeden Fall muß dieser Code-Abschnitt in einer Funktion landen (eventuell sogar ans Ende der Button2Click()).</p>
<p>deswegen weis ich auch nicht wie ich den fehler beheben soll<br />
ich möchte die 10 sortierten zahlen in eine listbox ausgeben lassen <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/1287378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287378</guid><dc:creator><![CDATA[Aicde]]></dc:creator><pubDate>Fri, 18 May 2007 12:48:14 GMT</pubDate></item></channel></rss>