<?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[Sortier Programm Kürzen]]></title><description><![CDATA[<p>Hallo und Guten tag <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="😉"
    /> ich habe vorkurzem mit C++ angefangen und wollte mir ein Sortier Programm schreiben. Habe auch eins Fertig. Aber mein Problem ist wenn ich nun 10 oder 15 Zahlen Sortieren will wird das program ja Unendlich lang und ich muss zuviel schreiben. hat jemand ne idee wie man das kürzen kann möglich muss es ja sein =D. schon mal Danke für viele nette Beiträge.</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link &quot;CCALENDR&quot;
#pragma resource &quot;*.dfm&quot;

int komma1=0, komma2=0, komma3=0;

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

 float zahl1, zahl2, zahl3, klein, mittel, gross;
 zahl1 = StrToFloat(Edit1-&gt;Text);
 zahl2 = StrToFloat(Edit2-&gt;Text);
 zahl3 = StrToFloat(Edit3-&gt;Text);

if((zahl1==zahl2) || (zahl1==zahl3) || (zahl2==zahl3))
{
Label4-&gt;Caption=&quot;Du hast leider verloren..\n Zwei/Drei gleiche Zahlen!&quot;;
klein=zahl1;
mittel=zahl2;
gross=zahl3;
}

if((zahl1&gt;zahl2) &amp;&amp; (zahl1&gt;zahl3))         {
          gross=zahl1;
      if(zahl2&gt;zahl3){
          klein=zahl3;
          mittel=zahl2;
      }
      if(zahl3&gt;zahl2){
          klein=zahl2;
          mittel=zahl3;
      }
      }

if((zahl2&gt;zahl1) &amp;&amp; (zahl2&gt;zahl3)) {
       gross=zahl2;
      if(zahl1&gt;zahl3){
         klein=zahl3;
         mittel=zahl1;
      }
      if(zahl3&gt;zahl1){
         klein=zahl1;
         mittel=zahl3;
      }
      }
if((zahl3&gt;zahl2) &amp;&amp; (zahl3&gt;zahl1)){
      gross=zahl3;
      if(zahl2&gt;zahl1){
         klein=zahl1;
         mittel=zahl2;
      }
      if(zahl1&gt;zahl2){
         klein=zahl2;
         mittel=zahl1;
      }
      }

if(RadioButton1-&gt;Checked) {
   Label1-&gt;Caption=FormatFloat(&quot;#,##0.####&quot;,(klein));
   Label2-&gt;Caption=FormatFloat(&quot;#,##0.####&quot;,(mittel));
   Label3-&gt;Caption=FormatFloat(&quot;#,##0.####&quot;,(gross));
   }
if(RadioButton2-&gt;Checked) {
   Label1-&gt;Caption=FloatToStr(gross)  ;
   Label2-&gt;Caption=FloatToStr(mittel);
   Label3-&gt;Caption=FloatToStr(klein);
                  }

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1-&gt;Clear();
Edit2-&gt;Clear();
Edit3-&gt;Clear();
Label1-&gt;Caption=&quot;&quot;;
Label2-&gt;Caption=&quot;&quot;;
Label3-&gt;Caption=&quot;&quot;;
Label4-&gt;Caption=&quot;Bitte Zahl eingeben. \n Bin wieder einsatzbereit&quot;;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &amp;Key)
{
//ASCII-Codes: 0-9 =&gt; 48-57 ; &quot;,&quot; =&gt;44 ; &quot;-&quot; =&gt; 45; BackSpace =&gt; 8
     if ((Key==44) &amp;&amp; (komma1&lt;1))   {
         komma1++;
         if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key ==44)  | (Key == 45) | (Key == 8)) return;
         else Key = 0;
         }
      if(komma1&gt;=1){
           if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &amp;Key)
{
//ASCII-Codes: 0-9 =&gt; 48-57 ; &quot;,&quot; =&gt;44 ; &quot;-&quot; =&gt; 45; BackSpace =&gt; 8
     if ((Key==44) &amp;&amp; (komma2&lt;1))   {
         komma2++;
         if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key ==44)  | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
         if(komma2&gt;=1){
           if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
  }
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &amp;Key)
{
//ASCII-Codes: 0-9 =&gt; 48-57 ; &quot;,&quot; =&gt;44 ; &quot;-&quot; =&gt; 45; BackSpace =&gt; 8
        if ((Key==44) &amp;&amp; (komma3&lt;1))   {
         komma3++;
         if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key ==44)  | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
         if(komma3&gt;=1){
           if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }

}
//---------------------------------------------------------------------------
</code></pre>
<p>Gruß ZarDocK</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/183656/sortier-programm-kürzen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 14:27:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/183656.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Jun 2007 08:55:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sortier Programm Kürzen on Thu, 07 Jun 2007 08:55:56 GMT]]></title><description><![CDATA[<p>Hallo und Guten tag <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="😉"
    /> ich habe vorkurzem mit C++ angefangen und wollte mir ein Sortier Programm schreiben. Habe auch eins Fertig. Aber mein Problem ist wenn ich nun 10 oder 15 Zahlen Sortieren will wird das program ja Unendlich lang und ich muss zuviel schreiben. hat jemand ne idee wie man das kürzen kann möglich muss es ja sein =D. schon mal Danke für viele nette Beiträge.</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link &quot;CCALENDR&quot;
#pragma resource &quot;*.dfm&quot;

int komma1=0, komma2=0, komma3=0;

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

 float zahl1, zahl2, zahl3, klein, mittel, gross;
 zahl1 = StrToFloat(Edit1-&gt;Text);
 zahl2 = StrToFloat(Edit2-&gt;Text);
 zahl3 = StrToFloat(Edit3-&gt;Text);

if((zahl1==zahl2) || (zahl1==zahl3) || (zahl2==zahl3))
{
Label4-&gt;Caption=&quot;Du hast leider verloren..\n Zwei/Drei gleiche Zahlen!&quot;;
klein=zahl1;
mittel=zahl2;
gross=zahl3;
}

if((zahl1&gt;zahl2) &amp;&amp; (zahl1&gt;zahl3))         {
          gross=zahl1;
      if(zahl2&gt;zahl3){
          klein=zahl3;
          mittel=zahl2;
      }
      if(zahl3&gt;zahl2){
          klein=zahl2;
          mittel=zahl3;
      }
      }

if((zahl2&gt;zahl1) &amp;&amp; (zahl2&gt;zahl3)) {
       gross=zahl2;
      if(zahl1&gt;zahl3){
         klein=zahl3;
         mittel=zahl1;
      }
      if(zahl3&gt;zahl1){
         klein=zahl1;
         mittel=zahl3;
      }
      }
if((zahl3&gt;zahl2) &amp;&amp; (zahl3&gt;zahl1)){
      gross=zahl3;
      if(zahl2&gt;zahl1){
         klein=zahl1;
         mittel=zahl2;
      }
      if(zahl1&gt;zahl2){
         klein=zahl2;
         mittel=zahl1;
      }
      }

if(RadioButton1-&gt;Checked) {
   Label1-&gt;Caption=FormatFloat(&quot;#,##0.####&quot;,(klein));
   Label2-&gt;Caption=FormatFloat(&quot;#,##0.####&quot;,(mittel));
   Label3-&gt;Caption=FormatFloat(&quot;#,##0.####&quot;,(gross));
   }
if(RadioButton2-&gt;Checked) {
   Label1-&gt;Caption=FloatToStr(gross)  ;
   Label2-&gt;Caption=FloatToStr(mittel);
   Label3-&gt;Caption=FloatToStr(klein);
                  }

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1-&gt;Clear();
Edit2-&gt;Clear();
Edit3-&gt;Clear();
Label1-&gt;Caption=&quot;&quot;;
Label2-&gt;Caption=&quot;&quot;;
Label3-&gt;Caption=&quot;&quot;;
Label4-&gt;Caption=&quot;Bitte Zahl eingeben. \n Bin wieder einsatzbereit&quot;;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &amp;Key)
{
//ASCII-Codes: 0-9 =&gt; 48-57 ; &quot;,&quot; =&gt;44 ; &quot;-&quot; =&gt; 45; BackSpace =&gt; 8
     if ((Key==44) &amp;&amp; (komma1&lt;1))   {
         komma1++;
         if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key ==44)  | (Key == 45) | (Key == 8)) return;
         else Key = 0;
         }
      if(komma1&gt;=1){
           if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &amp;Key)
{
//ASCII-Codes: 0-9 =&gt; 48-57 ; &quot;,&quot; =&gt;44 ; &quot;-&quot; =&gt; 45; BackSpace =&gt; 8
     if ((Key==44) &amp;&amp; (komma2&lt;1))   {
         komma2++;
         if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key ==44)  | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
         if(komma2&gt;=1){
           if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
  }
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &amp;Key)
{
//ASCII-Codes: 0-9 =&gt; 48-57 ; &quot;,&quot; =&gt;44 ; &quot;-&quot; =&gt; 45; BackSpace =&gt; 8
        if ((Key==44) &amp;&amp; (komma3&lt;1))   {
         komma3++;
         if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key ==44)  | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }
         if(komma3&gt;=1){
           if (((Key&gt;=48) &amp;&amp; (Key &lt;=57)) | (Key== 45) | (Key == 8)) return;
         else Key = 0;
         }

}
//---------------------------------------------------------------------------
</code></pre>
<p>Gruß ZarDocK</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1300542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1300542</guid><dc:creator><![CDATA[zardock]]></dc:creator><pubDate>Thu, 07 Jun 2007 08:55:56 GMT</pubDate></item><item><title><![CDATA[Reply to Sortier Programm Kürzen on Thu, 07 Jun 2007 09:25:07 GMT]]></title><description><![CDATA[<p>Also was du machst ist ja echt umständlich <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="😉"
    /> aber schon gut.<br />
Such mal nach bubblesort oder quicksort (qsort).</p>
<p>schirrmie</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1300559</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1300559</guid><dc:creator><![CDATA[schirrmie]]></dc:creator><pubDate>Thu, 07 Jun 2007 09:25:07 GMT</pubDate></item><item><title><![CDATA[Reply to Sortier Programm Kürzen on Thu, 07 Jun 2007 10:16:03 GMT]]></title><description><![CDATA[<p>hmm... such mal nach array vorher, dann geht es dir vielleicht von selbst auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1300592</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1300592</guid><dc:creator><![CDATA[rapso]]></dc:creator><pubDate>Thu, 07 Jun 2007 10:16:03 GMT</pubDate></item><item><title><![CDATA[Reply to Sortier Programm Kürzen on Thu, 07 Jun 2007 10:28:19 GMT]]></title><description><![CDATA[<p>du könntest einen Sortieralgorithmus entwerfen für ein belibig großes Array von Zahlen ... wenn dir das für den Anfang zu komplex ist, kannst du natürlich einen der üblichen Sortieralgorithmen, die mein Vorvorredner schon angesprochen aht, nehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1300606</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1300606</guid><dc:creator><![CDATA[Checker*amp*Murckser]]></dc:creator><pubDate>Thu, 07 Jun 2007 10:28:19 GMT</pubDate></item><item><title><![CDATA[Reply to Sortier Programm Kürzen on Mon, 11 Jun 2007 13:45:19 GMT]]></title><description><![CDATA[<p>am besten du nimmst dir einen der viiiielen sortieralgorithmen...<br />
==&gt; <a href="http://www.zfx.info/Tutorials.php?ID=79" rel="nofollow">http://www.zfx.info/Tutorials.php?ID=79</a> &lt;==<br />
wie z.B.<br />
Bubblesort...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

using namespace std;

int eingabe_und_sortieren()
{
    int liste[20];
    int merker=0;
    int flag=0;
    int j=0;
    int i=0;
    srand(time(NULL));
    srand(rand());                              /* startwert für rand() */
    cout &lt;&lt; &quot;alte liste:&quot;&lt;&lt;endl;
    for(i=0;i&lt;=20;i++)                              /* liste füllen und Ausgabe alte liste*/
    {
        liste[i]=rand();
         cout &lt;&lt; liste[i] &lt;&lt; endl;
    }
    cout &lt;&lt; endl&lt;&lt; endl &lt;&lt;&quot;Sortieren...&quot;&lt;&lt;endl &lt;&lt;endl;

    for(int i = 0; i &lt; 20; i++)                    /* sortieren */    /* wichtig ist die anzahl der durchläufe */
    {
        for(int j = 0; j &lt; (21 - (i + 1)); j++)         /* die 21 ist eins mehr als die anzahl der zahlen */
        {
            if(liste[j] &gt; liste[j + 1]) {                /* wenn liste[j] größer ist als [liste[j+1] */
            merker = liste[j];                           /* merke liste[j] */
            liste[j] = liste[j + 1];                     /* schreibe liste[j] in liste[j+1] */   
            liste[j + 1] = merker;                       /*schreibe merker in liste [j+1] */                                
        }
    }

}

    cout &lt;&lt; endl &lt;&lt; &quot;neue liste:&quot;&lt;&lt;endl;
    for(i=0;i&lt;=20;i++)                                /* Ausgabe neue liste*/
    {
        cout &lt;&lt; liste[i] &lt;&lt; endl;
    }
    return 0;
}        

int main()                                            /* Main - FKt */
{
    char c;
    eingabe_und_sortieren();
    cin &gt;&gt; c;
    return 0;
}
</code></pre>
<p>hoffe es hilft dir ...</p>
<p>grüße<br />
zen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1303155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1303155</guid><dc:creator><![CDATA[zenfu]]></dc:creator><pubDate>Mon, 11 Jun 2007 13:45:19 GMT</pubDate></item></channel></rss>