[C/C++] Lottozahlen.C

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von FynnY, 15. Februar 2007 .

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 15. Februar 2007
    Lottozahlen.C

    Moin Leute,
    ich hab mal wieder das alte " Turbo C " ausgepackt. Nun hab ich mal wieder bisschen gespielt und ein Lottoprogramm geschrieben. Leider kommt nun ein Problem, wo ich nicht weiter weiß. Bei googel gibbet auch keine gescheite hilfe. Also
    1. Ich definiere ein Array "Lottofeld" fülle dies mit den Zahlen 1-49
    2. Ich teile einem neuem Array 6 ZUFÄLLIGE Zahlen zu
    3. Ich gebe die Gewinnzahlen der Reihe nach aus
    Nun möchte ich jedoch noch etwas erweitern, ich möchte, dass die Zahlen der größe nach ausgegeben werden! Da komm ich nun echt nicht weiter
    Hat jemand von euch Ahnung?
    Code:
    #include <stdio.h>
    #include <time.h>
    
    kopf(char eingabe[25])
    {
     int x,y;
     printf(" %c",218);
     for(x=1;x<=43;x++)
     {
     printf("%c",196);
     }
     printf("%c",191);
     printf("\n %c %c",179,179);
     printf("\n %c%25s %c",179,eingabe,179);
     printf("\n %c %c",179,179);
     printf("\n %c %c",179,179);
     printf("\n %c %c",179,179);
     printf("\n %c (c) H.b. %c",179,179);
     printf("\n %c",192);
     for(y=1;y<=43;y++)
     {
     printf("%c",196);
     }
     printf("%c",217);
    }
    int zufall(){
     return rand()%49;
     }
    main(){
     int Lottofeld[49], x, y, z, anzahl, zzahl, anzahl2=0, gewinn[6], los=0, array[6];
     clrscr();
     system("cls");
     srand(time(NULL));
     kopf(" Lottospiel ");
     printf("\n");
    /* Lottofeld[anzahl] wird mit zahlen von 1-48 gefüllt */
     for(anzahl=0;anzahl<=48;anzahl++){
     Lottofeld[anzahl]=anzahl+1;}
    /* Die Zzahlen werden dem gewinn[los] zugeteilt */
     do{
     zzahl=zufall();
     if(Lottofeld[zzahl]!=0){
     gewinn[los]=Lottofeld[zzahl];
     Lottofeld[zzahl]=0;
     anzahl2++;
     los++;}
     }while(anzahl2!=49);
    /* Ausgabe der Gewinnzahlen */
     printf("Die Gewinnzahlen: \n\t>");
     for(los=0;los<=5;los++){
     printf("%4i",gewinn[los]);
     }
     getch();
     }
    
     
  2. 15. Februar 2007
    AW: Lottozahlen.C

    Du könntest das Array sortieren. ;-)

    c++ array sort - Google-Suche
    Arrays in C++ - Sorting
     
  3. 15. Februar 2007
    AW: Lottozahlen.C

    Ich hätte dass Array mit Bubblesort sortiert.

    Bubblesort – Wikipedia

    Gruß

    Hamml
     
  4. 17. Februar 2007
    AW: Lottozahlen.C

    bau dir eine neue klasse und sortiere die zahlen mit (einer) quicksort-funktion(en)!

    die beispiele sind relativ eindeutig und leicht zu verstehen....

    Quicksort – Wikipedia

    have fun
     
  5. 22. Februar 2007
    AW: Lottozahlen.C

    thx, habs nu mit bubblesort gemacht, hat prima geklappt
    !
     
  6. 22. Februar 2007
    AW: Lottozahlen.C

    [X] Erledigt

    ~Close~

    Knusperkeks
     
  7. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.