<?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[int variablen sortieren.]]></title><description><![CDATA[<p>Hallo an alle,<br />
habe ein kleines problemm:<br />
Die sache ist die ich habe 6 vareablen von type int.<br />
z.B a=5,b=10,c=45,d=50,e=29.<br />
so, jetz will ich variablen sortieren so das die grosste variable zuerst angezeigt wird und dann die zweit grosste u.s.w.<br />
Wie kann ich das am besten machen ???<br />
Danke !!!!.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/292665/int-variablen-sortieren</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 18:09:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/292665.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 15 Sep 2011 08:00:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 08:00:50 GMT]]></title><description><![CDATA[<p>Hallo an alle,<br />
habe ein kleines problemm:<br />
Die sache ist die ich habe 6 vareablen von type int.<br />
z.B a=5,b=10,c=45,d=50,e=29.<br />
so, jetz will ich variablen sortieren so das die grosste variable zuerst angezeigt wird und dann die zweit grosste u.s.w.<br />
Wie kann ich das am besten machen ???<br />
Danke !!!!.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2119575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119575</guid><dc:creator><![CDATA[runix1981]]></dc:creator><pubDate>Thu, 15 Sep 2011 08:00:50 GMT</pubDate></item><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 08:03:36 GMT]]></title><description><![CDATA[<p>Wieso verwendest du überhaupt einzelne Variablen (noch dazu mit so aussagekräftigen Namen)? Pack sie lieber in ein Array oder einen STL-Container, dann machst du dir vieles einfacher (u.a. kannst du dann einmal std::sort() drüberjagen, um sie zu sortieren).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2119578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119578</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 15 Sep 2011 08:03:36 GMT</pubDate></item><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 08:27:02 GMT]]></title><description><![CDATA[<p>std::vector&lt;int&gt;<br />
std::sort</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2119586</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119586</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 15 Sep 2011 08:27:02 GMT</pubDate></item><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 08:57:15 GMT]]></title><description><![CDATA[<p>Wilde Idee um Lehrer zu beeindrucken: Mit 12 Vergleich-Vertausch-Operationen in einer fest einprogrammierten Reihenfolge kannst du sechs Werte (egal ob als Feld oder a,b,c,d,e,f genannt) optimal sortieren:<br />
<a href="http://jgamble.ripco.net/cgi-bin/nw.cgi?inputs=6&amp;algorithm=best&amp;output=text" rel="nofollow">http://jgamble.ripco.net/cgi-bin/nw.cgi?inputs=6&amp;algorithm=best&amp;output=text</a><br />
Und dann sind du und dein Lehrer erst einmal eine gute Stunde damit beschäftigt zu durchschauen, wie das funktioniert <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/2119596</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119596</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 15 Sep 2011 08:57:15 GMT</pubDate></item><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 11:01:03 GMT]]></title><description><![CDATA[<p>Er soll das zum Lernen selbst machen, ohne vorhandene Sort-Funktionen zu verwenden? <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="😕"
    /> Bei nur 6 Variablen geht das doch mit einer Reihe von if-Abfragen und einem Sortierarray. Kann man was mit lernen! Nicht immer ist alles schlecht, was ein Lehrer als Aufgabe stellt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2119650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119650</guid><dc:creator><![CDATA[berniebutt]]></dc:creator><pubDate>Thu, 15 Sep 2011 11:01:03 GMT</pubDate></item><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 11:33:31 GMT]]></title><description><![CDATA[<p>du kannst es auch mit vielen if verzweigunen programmieren,wenn du kein stl benutzen darfst zb if(a&lt;b&amp;&amp;...)</p>
<p>ups zu langsam <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/2119671</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119671</guid><dc:creator><![CDATA[kantaki]]></dc:creator><pubDate>Thu, 15 Sep 2011 11:33:31 GMT</pubDate></item><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 12:31:16 GMT]]></title><description><![CDATA[<p>hier mal eine Beispielimplementation für SeppJ's Vorschlag^^</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

struct comp_pair
{
    int ia_; // index a
    int ib_; // index b
};

comp_pair comp_table[12] =
{
    { 1, 2 },
    { 4, 5 },
    { 0, 2 },
    { 3, 5 },
    { 0, 1 },
    { 3, 4 },
    { 2, 5 },
    { 0, 3 },
    { 1, 4 },
    { 2, 4 },
    { 1, 3 },
    { 2, 3 }
};

void comp_and_swap(int &amp; a, int &amp; b)
{
    int tmp = a &lt; b ? a : b;
    b = a &lt; b ? b : a;
    a = tmp;
}

void sort6(int * numbers)
{
    for (int n = 0; n &lt; 12; ++n)
    {
        comp_pair &amp; comparison = comp_table[n];
        comp_and_swap(numbers[comparison.ia_], numbers[comparison.ib_]);
    }
}

int main(void)
{
    int numbers[6];
    for (int n = 0; n &lt; 6; ++n)
    {
        std::cout &lt;&lt; (n + 1) &lt;&lt; &quot;. Number: &quot;;
        std::cin &gt;&gt; numbers[n];
    }

    sort6(numbers);

    for (int n = 0; n &lt; 6; ++n)
        std::cout &lt;&lt; (n ? &quot;, &quot; : &quot;&quot;) &lt;&lt; numbers[n];
    std::cout &lt;&lt; std::endl;

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2119689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119689</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Thu, 15 Sep 2011 12:31:16 GMT</pubDate></item><item><title><![CDATA[Reply to int variablen sortieren. on Thu, 15 Sep 2011 13:54:24 GMT]]></title><description><![CDATA[<p>Danke an alle hat mir echt geholfen !!!!<br />
Super</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2119755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2119755</guid><dc:creator><![CDATA[runix1981]]></dc:creator><pubDate>Thu, 15 Sep 2011 13:54:24 GMT</pubDate></item></channel></rss>