[C/C++] Sortieralgorithmus

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von Kirill, 17. Mai 2009 .

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 17. Mai 2009
    Sortieralgorithmus

    Hallo Leute,
    bin gerade an einem Sortieralgorithmus dran. Habe es bereits hinbekommen Zahlen zu sortieren. Jedoch will das ganze nicht so richtig mit Namen.

    Sortierungsalgorithmus für Zahlen:
    Code:
    [COLOR="Red"]struct test
    {
     string name;
    }info[5]; [/COLOR]
    
    
    [COLOR="Blue"]int main()
    { [/COLOR]
    
    
    for (int a = 0; a < info[zahlcounter].anzahl; a++)
     {
     for (int x=0; x<6; x++)
     {
     
     for (int y=0; y<5; y++)
     {
     
     if (info[zahlcounter].tipp[a][y] > Info[zahlcounter].tipp[a][y+1]) 
     {
     int temp = info[zahlcounter].tipp[a][y]; 
     info[zahlcounter].tipp[a][y] = info[zahlcounter].tipp[a][y+1];
     info[zahlcounter].tipp[a][y+1] = temp;
     }
    
     }
    
    
     }
     }
    
    [COLOR="Blue"]}[/COLOR]
    
    
    



    Wie sieht der Algorithmus für Buchstaben bzw. ganze Namen aus?


    Code:
    [COLOR="Red"]struct test
    {
     string name;
    }info[5]; [/COLOR]
    
    
    [COLOR="Blue"]int main()
    { [/COLOR]
    
    
    for (int a = 0; a < info[zahlcounter].anzahl; a++)
     {
     for (int x=0; x<6; x++)
     {
     
     for (int y=0; y<5; y++)
     {
     
     if (info[zahlcounter].name > info[zahlcounter+1].name) 
     {
     int temp = info[zahlcounter].name; 
     info[zahlcounter].name = info[zahlcounter+1].name;
     info[zahlcounter+1].name = temp;
     }
    
     }
    
    
     }
     }
    
    [COLOR="Blue"]}[/COLOR]
    
    
    


    Danke im Voraus!
     
  2. 17. Mai 2009
    AW: Sortieralgorithmus

    Ich hab zwar keine Ahnung von C/C++ oder sonstigem, aber in Java gibts dafür n schönes Package, dass man nach Unicode bestimmte Wertigkeiten bekommt. So kann man also nach Unicode sortieren. Guck doch einfach mal obs das für C/C++ auch gibt. Ansonsten werden da sicher gute Lösungen bei google angeboten.

    Also mal den Gedanken in eine Richtung gelenkt hoffe das hilft.
     
  3. 17. Mai 2009
    AW: Sortieralgorithmus

    Ich habe bereits gegoogelt, aber nichts vernünftiges gefunden.


    OK, ich habe es selber hinbekommen!
     
  4. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.