<?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[[gelöst]Selection Sort funzt net...]]></title><description><![CDATA[<p>Einen schönen Sonntag Vormittag wünsch ich euch, hoffe ihr habt die Zeitumstellung gut verkraftet <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>
<p>Mal wieder macht c++ nicht, was ich will obwohl ich mir schon seit einigen Stunden den Kopf zerbreche woran es liegt...<br />
Google hilft mir nicht und mein c++ Buch auch nicht...<br />
Wie das Thema schon sagt, soll ich einen Sortieralgorithmus schreiben...<br />
Ich habe mich für den Selection Sort entschieden..<br />
So sieht er bei mir aus:</p>
<p>*/</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int main () {</p>
<p>double a[10] = { 12.6 , 33.77 , 51.32 , 95.11 , 19.78 ,<br />
35.34 , 85.18 , 89.0 , 37.5 , 24.1 };</p>
<p>double median; // Bis hier war die Aufgabe vorgegeben<br />
int i , k , t, min;<br />
int n;</p>
<p>for (i=0; i&lt; n-1; i++ ) //Schleife für die n-1 Durchläufe<br />
{ <strong>// 1.</strong><br />
min =i;<br />
for (k= i+1 ; k&lt;n ; k++) //Ermittlung des kleinsten Wertes<br />
{<br />
if( a[k] &lt; a[min])<br />
min=k; <strong>//2.</strong><br />
}</p>
<p>t=a[min]; //Vertauschen der Werte..<br />
a[min]= a[i]; <strong>// 3.</strong><br />
a[i] = t;</p>
<p>}<br />
}<br />
return 0; <strong>//4.</strong></p>
<p>}</p>
<p>zu 1. invalid operands of types `int' and `&lt;unknown type&gt;' to binary `operator&lt;'</p>
<p>zu 2. converting to `int' from `double'</p>
<p>zu 3. invalid operands of types `int' and `&lt;unknown type&gt;' to binary `operator&lt;=</p>
<p>zu 4. synthax error...</p>
<p>Ich bin mir aber super sicher,dass so dere SelecSort funktionieren sollte...</p>
<p>Wie immer bin ich über jede Hilfe dankbar <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>
]]></description><link>https://www.c-plusplus.net/forum/topic/276328/gelöst-selection-sort-funzt-net</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 10:18:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/276328.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 31 Oct 2010 11:14:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [gelöst]Selection Sort funzt net... on Sun, 31 Oct 2010 14:18:00 GMT]]></title><description><![CDATA[<p>Einen schönen Sonntag Vormittag wünsch ich euch, hoffe ihr habt die Zeitumstellung gut verkraftet <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>
<p>Mal wieder macht c++ nicht, was ich will obwohl ich mir schon seit einigen Stunden den Kopf zerbreche woran es liegt...<br />
Google hilft mir nicht und mein c++ Buch auch nicht...<br />
Wie das Thema schon sagt, soll ich einen Sortieralgorithmus schreiben...<br />
Ich habe mich für den Selection Sort entschieden..<br />
So sieht er bei mir aus:</p>
<p>*/</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int main () {</p>
<p>double a[10] = { 12.6 , 33.77 , 51.32 , 95.11 , 19.78 ,<br />
35.34 , 85.18 , 89.0 , 37.5 , 24.1 };</p>
<p>double median; // Bis hier war die Aufgabe vorgegeben<br />
int i , k , t, min;<br />
int n;</p>
<p>for (i=0; i&lt; n-1; i++ ) //Schleife für die n-1 Durchläufe<br />
{ <strong>// 1.</strong><br />
min =i;<br />
for (k= i+1 ; k&lt;n ; k++) //Ermittlung des kleinsten Wertes<br />
{<br />
if( a[k] &lt; a[min])<br />
min=k; <strong>//2.</strong><br />
}</p>
<p>t=a[min]; //Vertauschen der Werte..<br />
a[min]= a[i]; <strong>// 3.</strong><br />
a[i] = t;</p>
<p>}<br />
}<br />
return 0; <strong>//4.</strong></p>
<p>}</p>
<p>zu 1. invalid operands of types `int' and `&lt;unknown type&gt;' to binary `operator&lt;'</p>
<p>zu 2. converting to `int' from `double'</p>
<p>zu 3. invalid operands of types `int' and `&lt;unknown type&gt;' to binary `operator&lt;=</p>
<p>zu 4. synthax error...</p>
<p>Ich bin mir aber super sicher,dass so dere SelecSort funktionieren sollte...</p>
<p>Wie immer bin ich über jede Hilfe dankbar <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1973050</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1973050</guid><dc:creator><![CDATA[faC1al]]></dc:creator><pubDate>Sun, 31 Oct 2010 14:18:00 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]Selection Sort funzt net... on Sun, 31 Oct 2010 11:21:09 GMT]]></title><description><![CDATA[<p>n ist nicht initialisiert und eine Klammer ist zuviel. Du kannst nicht bis n-1 durchlaufen, wenn es für n keinen Wert gibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1973051</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1973051</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Sun, 31 Oct 2010 11:21:09 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]Selection Sort funzt net... on Sun, 31 Oct 2010 11:33:51 GMT]]></title><description><![CDATA[<p>Danke schonmal für die schnelle Antwort ..</p>
<p>Also muss ich &quot;n&quot; einen werte geben?<br />
z.b<br />
int n;<br />
n=0;</p>
<p>ODer versteh ich dich gerade falsch ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1973057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1973057</guid><dc:creator><![CDATA[faC1al]]></dc:creator><pubDate>Sun, 31 Oct 2010 11:33:51 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]Selection Sort funzt net... on Sun, 31 Oct 2010 11:37:06 GMT]]></title><description><![CDATA[<p>Wenn du 0 gibst hast du ein Laufzeitfehler, da du die Schleife nicht bis 0-1 laufen lassen kannst. Aber im Prinzip ja. Nur kann man das besser machen:</p>
<p>int n = 10;</p>
<p>Gleich initialisieren ist besser.</p>
<p>Außerdem würde ich i und k in den Schleifen deklarieren also so:</p>
<p>for (int i = 0; ....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1973058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1973058</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Sun, 31 Oct 2010 11:37:06 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]Selection Sort funzt net... on Sun, 31 Oct 2010 12:19:56 GMT]]></title><description><![CDATA[<p>Es ist aber nicht nötig alles in den Klammern zu intialisieren oder?</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main () {

	double a[10] = { 12.6 , 33.77 , 51.32 , 95.11 , 19.78 ,
		           35.34 , 85.18 , 89.0 , 37.5 , 24.1 };

double median;             //Unuser Variable
int i , k , t, min;
int n=10;

for (i=0; i&lt; n-1; i++ )
{
	min =i;
	for (k= i+1 ; k&lt;n ; k++)
	{
		if( a[k] &lt; a[min])
		min=k;
	}

	t=a[min];        // converting to int from double
	a[min]= a[i]; 
	a[i] = t;               

}
cout &lt;&lt; &quot;Median: &quot; &lt;&lt; median &lt;&lt;endl;

return 0;          //expected unqualified-id before &quot;return&quot;
}                     //expected declaration before '}' token
</code></pre>
<p>So siehts jetzt aus, geht aber immernoch net <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=";D"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1973059</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1973059</guid><dc:creator><![CDATA[faC1al]]></dc:creator><pubDate>Sun, 31 Oct 2010 12:19:56 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]Selection Sort funzt net... on Sun, 31 Oct 2010 14:02:37 GMT]]></title><description><![CDATA[<p>Vor dem Vertauschen fehlt bei dir die Abfrage, ob i!=min ist.<br />
Siehe auch <a href="http://codepad.org/I3KBsr4h" rel="nofollow">hier</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1973127</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1973127</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Sun, 31 Oct 2010 14:02:37 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst]Selection Sort funzt net... on Sun, 31 Oct 2010 14:17:30 GMT]]></title><description><![CDATA[<p>Perfekt...<br />
Hat wunderbar geklappt...<br />
Vielen Dank allen beteiligten <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1973135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1973135</guid><dc:creator><![CDATA[faC1al]]></dc:creator><pubDate>Sun, 31 Oct 2010 14:17:30 GMT</pubDate></item></channel></rss>