Brauche Hilfe bei Pferderennen



  • Hier mein Programm
    bei der Pferderennen If schleife komm ich nicht weiter und brauche hilfe die warscheinlichkeiten der einzelnen Pferde zu berechen. Bis jetzt ist es einfach nur eine 1/6 warscheinlichkeit.```cpp

    #include <iostream>
    #include <time.h>
    #include <cstdlib>
    #include <string>
    #include <ciso646>
    #include <stdlib.h>
    #include <cctype>
    using namespace std;
    
    long long int Kontostand = 10000;
    string Spiel;
    int y;
    
    string display  = "|=====================================================================|";
    string display2 = "|   CCCCC      A        SSSSSSSSS   IIIIIIIII  NN     NN    OOOOOOOO  |   ";
    string display3 = "| CC          A  A      SS             III     NN N   NN   OO      OO |   ";
    string display4 = "| CC         A    A     SSSSSSSSS      III     NN  N  NN   OO      OO |   ";
    string display5 = "| CC        AAAAAAAA           SS      III     NN   N NN   OO      OO | ";
    string display6 = "|   CCCCC  A        A   SSSSSSSSS   IIIIIIIII  NN     NN    OOOOOOOO  |";
    string display7 = "|=====================================================================|";
    
    
    int main(){
        while(y==0){
            system("CLS");
            cout << display <<endl;
            cout << display2 <<endl;
            cout << display3 <<endl;
            cout << display4 <<endl;
            cout << display5 <<endl;
            cout << display6 <<endl;
            cout << display7 <<endl;
            cout << "Du hast noch: " << Kontostand << " coins." <<endl; 
            cout << "was Mochtest du Spielen: " <<endl;
            cout << "Zur auswahl stehen:" <<endl;
            cout << "Blackjack(B), Pferderennen(P), Slot(S), Roulette(R)" <<endl;
            cin >> Spiel;
            
            if(Spiel == "S" || Spiel == "s" || Spiel == "Slot"){
                int ersteZahl;
                int zweiteZahl;
                int dritteZahl;
                string eingabe;
                int Spielgeld;
                int u,i;
                int ok;
                system("CLS");
                string adisplay  = "              |-------------------------------------|";
                string adisplay2 = "              |#####################################|";
                string adisplay3 = "              |#           |           |           #|";
                //string display4 = "|#     " << ersteZahl << "     |     " << zweiteZahl << "     |     " << dritteZahl << "     #|";
                string adisplay5 = "              |#           |           |           #|";
                string adisplay6 = "              |#####################################|";
                string adisplay7 = "              |-------------------------------------|";
                cout << display <<endl;
                cout << display2 <<endl;
                cout << display3 <<endl;
                cout << display4 <<endl;
                cout << display5 <<endl;
                cout << display6 <<endl;
                cout << display7 <<endl;
                srand(time(0));
                while(i == 0){
                u = 0;
                if(Kontostand == 0){
                    string Seele;
                    int Pleite;
                    int Pleite2;
                        cout << "Du bist Pleite, mochtest du russisches Roulette Spielen Um 10000 Coins zu gewinnen." <<endl;
                        cout << "Ja oder Nein?" <<endl;
                        cin >> Seele;
                        if(Seele == "J" || Seele == "j" || Seele == "Ja" || Seele == "ja"){
                            Pleite = (rand() % 6) + 1;
                            Pleite2 = (rand() % 6) + 1;
                            if(Pleite == Pleite2){
                                 cout << "Du bist tot sorry" <<endl;
                                i++;
                                y++;
                            }
                            else{
                                cout << "Du hattest gluck hier hast du weitere 5000 Coins." <<endl;
                                Kontostand = Kontostand + 5000;
                                i++;
                            }
                        }
                        else if(Seele == "N"){
                            cout << "Schade war ein versuch wert." <<endl;
                            i++;
                            y++;
                        }
                        else{
                            cout << "Du laberst scheiße und bist tot." <<endl;
                            i++;
                            y++;
                        }
                    }
                cout << "Du hast noch: " << Kontostand << " coins." <<endl;
                cout << "Willst du eine Runde Spielen(S) oder willst du aufhoren(A)" <<endl;
                cin >> eingabe;
                    if(eingabe == "A" || eingabe == "a"){
                        i++;
                    }
    
                    if(eingabe == "S" || eingabe == "s"){
                        cout << "Mit wie vielen Coins willst du spielen?" <<endl;
                        while (u == 0){
                            cin >> Spielgeld;
                            if(Spielgeld > Kontostand){
                                cout << "So viel coins hast du nicht" <<endl;
                                cout << "Deine Kontostand betragt: " << Kontostand << " coins"<<endl;
                                cout << "Mit wie vielen Coins willst du spielen?" << endl;
                            }
                            else{
                                u++;
                            }
                        }
                            Kontostand = Kontostand - Spielgeld;
                            
                            cout << display << endl;
                            cout << display2 << endl;
                            cout << display3 << endl;
    
                            for(int p= 0; p <50; p++){
                                ersteZahl = (rand() % 8) +1;
                                zweiteZahl = (rand() % 8) +1;
                                dritteZahl = (rand() & 8) +1;
                                system("CLS");
                                cout << adisplay << endl;
                                cout << adisplay2 << endl;
                                cout << adisplay3 << endl;
                                cout << "              |#     " << ersteZahl << "     |     " << zweiteZahl << "     |     " << dritteZahl << "     #|" << endl;
                                cout << adisplay5 << endl;
                                cout << adisplay6 << endl;
                                cout << adisplay7 << endl;
                            }                
    
                        if (ersteZahl == zweiteZahl || ersteZahl == dritteZahl || zweiteZahl == dritteZahl){
                            system("CLS");
                            cout << display <<endl;
                            cout << display2 <<endl;
                            cout << display3 <<endl;
                            cout << display4 <<endl;
                            cout << display5 <<endl;
                            cout << display6 <<endl;
                            cout << display7 <<endl;
                            cout << adisplay << endl;
                            cout << adisplay2 << endl;
                            cout << adisplay3 << endl;
                            cout << "              |#     " << ersteZahl << "     |     " << zweiteZahl << "     |     " << dritteZahl << "     #|" << endl;
                            cout << adisplay5 << endl;
                            cout << adisplay6 << endl;
                            cout << adisplay7 << endl;
                            cout << "Du hast ein Paar!" << endl;
                            Kontostand = Kontostand + Spielgeld*3;
                        }
                        else if(ersteZahl == zweiteZahl == dritteZahl){
                            system("CLS");
                            cout << display <<endl;
                            cout << display2 <<endl;
                            cout << display3 <<endl;
                            cout << display4 <<endl;
                            cout << display5 <<endl;
                            cout << display6 <<endl;
                            cout << display7 <<endl;
                            cout << adisplay << endl;
                            cout << adisplay2 << endl;
                            cout << adisplay3 << endl;
                            cout << "              |#     " << ersteZahl << "     |     " << zweiteZahl << "     |     " << dritteZahl << "     #|" << endl;
                            cout << adisplay5 << endl;
                            cout << adisplay6 << endl;
                            cout << adisplay7 << endl;
                            cout << "Du hast ein Drilling!" << endl;
                            Kontostand = Kontostand + Spielgeld*30;
                        }
                        else{
                            system("CLS");
                            cout << display <<endl;
                            cout << display2 <<endl;
                            cout << display3 <<endl;
                            cout << display4 <<endl;
                            cout << display5 <<endl;
                            cout << display6 <<endl;
                            cout << display7 <<endl;
                            cout << adisplay << endl;
                            cout << adisplay2 << endl;
                            cout << adisplay3 << endl;
                            cout << "              |#     " << ersteZahl << "     |     " << zweiteZahl << "     |     " << dritteZahl << "     #|" << endl;
                            cout << adisplay5 << endl;
                            cout << adisplay6 << endl;
                            cout << adisplay7 << endl;
                            cout << "Du hast verloren" << endl;
                            u++;
                        }
                    }
                }
            }
            if(Spiel == "B" || Spiel == "b" || Spiel == "Blackjack"){
                string eingabe;
                int n,u,m,w,z,i;
                int Karte;
                int Spielerwert;
                int Bank;
                string eingabe2;
                int Spielgeld;
                srand(time(0));
                system("CLS");
                cout << display <<endl;
                cout << display2 <<endl;
                cout << display3 <<endl;
                cout << display4 <<endl;
                cout << display5 <<endl;
                cout << display6 <<endl;
                cout << display7 <<endl;
                while(i == 0){
                    z = 0;
                    u = 0;
                    w = 0;
                    m = 0;
                    Spielerwert = 0;
                    Bank = 0;
                    if(Kontostand == 0){
                    string Seele;
                    int Pleite;
                    int Pleite2;
                        cout << "Du bist Pleite, mochtest du russisches Roulette Spielen Um 10000 Coins zu gewinnen." <<endl;
                        cout << "Ja oder Nein?" <<endl;
                        cin >> Seele;
                        if(Seele == "J" || Seele == "j" || Seele == "Ja" || Seele == "ja"){
                            Pleite = (rand() % 6) + 1;
                            Pleite2 = (rand() % 6) + 1;
                            if(Pleite == Pleite2){
                                 cout << "Du bist tot sorry" <<endl;
                                i++;
                                y++;
                            }
                            else{
                                cout << "Du hattest gluck hier hast du weitere 5000 Coins." <<endl;
                                Kontostand = Kontostand + 5000;
                                i++;
                            }
                        }
                        else if(Seele == "N"){
                            cout << "Schade war ein versuch wert." <<endl;
                            i++;
                            y++;
                        }
                        else{
                            cout << "Du laberst scheiße und bist tot" <<endl;
                            i++;
                            y++;
                        }
                    }
                    else{
                        cout << "Du hast noch: " << Kontostand << " coins." <<endl;
                        cout << "Willst du eine Runde Spielen(S) oder willst du Aufstehen(A)" <<endl;
                        cin >> eingabe;
                        if(eingabe == "A" || eingabe == "a"){
                            system("CLS");
                            cout << display <<endl;
                            cout << display2 <<endl;
                            cout << display3 <<endl;
                            cout << display4 <<endl;
                            cout << display5 <<endl;
                            cout << display6 <<endl;
                            cout << display7 <<endl;
                            i++;
                        }
                        if(eingabe == "S" || eingabe == "s"){
                            cout << "Mit wie vielen Coins mochtest du Spielen" <<endl;
    
                            while(z == 0){
                            cin >> Spielgeld;
                            if(Spielgeld > Kontostand){
                                cout << "So viele Coins hast du nicht" <<endl;
                                cout << "Dein Kontostand: " << Kontostand << " Coins" <<endl;
                                cout << "Mit wie vielen Coins mochtest du Spielen" <<endl;
                                }
                            else{
                                z++;
                            }
                            }
                            Kontostand = Kontostand - Spielgeld;
                                while(u == 0){
    
                                    if(w == 1){
                                        system("CLS");
                                        cout << display <<endl;
                                        cout << display2 <<endl;
                                        cout << display3 <<endl;
                                        cout << display4 <<endl;
                                        cout << display5 <<endl;
                                        cout << display6 <<endl;
                                        cout << display7 <<endl;
                                        cout << "Du hast gewonnen" <<endl;
                                        cout << "Du hast: " << Spielerwert <<endl;
                                        cout << "Das Haus hat: " << Bank <<endl;
                                        Kontostand = Kontostand + Spielgeld * 2;
                                        u++;
                                    }
                                    if(Spielerwert == 21){
                                        system("CLS");
                                        cout << display <<endl;
                                        cout << display2 <<endl;
                                        cout << display3 <<endl;
                                        cout << display4 <<endl;
                                        cout << display5 <<endl;
                                        cout << display6 <<endl;
                                        cout << display7 <<endl;
                                        cout << "Du hast gewonnen!" <<endl;
                                        Kontostand = Kontostand + Spielgeld * 2;
                                        cout << "Du hast: " << Spielerwert <<endl;
                                        cout << "Das Haus hat.: " << Bank <<endl;
                                        u++;
                                    }
                                    if(Spielerwert > 21){
                                        system("CLS");
                                        cout << display <<endl;
                                        cout << display2 <<endl;
                                        cout << display3 <<endl;
                                        cout << display4 <<endl;
                                        cout << display5 <<endl;
                                        cout << display6 <<endl;
                                        cout << display7 <<endl;
                                        cout << "Du hast verloren" <<endl;
                                        cout << "Du hast: " << Spielerwert <<endl;
                                        u++;
                                    }
    
                                    if(u == 0){
                                        system("CLS");
                                        cout << display <<endl;
                                        cout << display2 <<endl;
                                        cout << display3 <<endl;
                                        cout << display4 <<endl;
                                        cout << display5 <<endl;
                                        cout << display6 <<endl;
                                        cout << display7 <<endl;
                                        cout << " " <<endl;
                                        cout << "Du hast: " << Spielerwert <<endl;
                                        cout << "Das Haus hat: " << Bank <<endl;
                                        cout << " " <<endl;
                                        cout << "Willst du noch eine Karte(k) oder aufhoren(a)" <<endl;
                                        cin >> eingabe2;
                                    }
                                    if(eingabe2 == "a" || eingabe2 == "A"){
    
                                        while(m == 0){
    
                                            if(Bank > 21){
                                                m++;
                                                w++;
                                            }
                                            else if(Bank > Spielerwert){
                                                system("CLS");
                                                cout << display <<endl;
                                                cout << display2 <<endl;
                                                cout << display3 <<endl;
                                                cout << display4 <<endl;
                                                cout << display5 <<endl;
                                                cout << display6 <<endl;
                                                cout << display7 <<endl;
                                                cout << "Du hast verloren!" <<endl;
                                                cout << "Die bank hat: " << Bank <<endl;
                                                cout << "Du hast: " << Spielerwert <<endl;
                                                m++;
                                                u++;
                                            }
                                            else if(Bank == Spielerwert){
                                                cout << "Unentschieden!" <<endl;
                                                Kontostand = Kontostand + Spielgeld;
                                                m++;
                                                u++;
                                            }
                                            else if(Bank <= Spielerwert){
                                            Karte = (rand() % 52) + 1;
                                            if(Karte == 1 || Karte == 2 || Karte == 3 || Karte == 4){
                                                if(21 <= Bank + 11 ){
                                                Bank = 1 + Bank;
                                                }
                                                else{
                                                Bank = 11 + Bank;
                                                }
                                            }
                                            else if(Karte == 5 || Karte == 6 || Karte == 7 || Karte == 8){
                                                Bank = 2 + Bank;
                                            }
                                            else if(Karte == 9 || Karte == 10 || Karte == 11 || Karte == 12){
                                                Bank = 3 + Bank;
                                            }
                                            else if(Karte == 13 || Karte == 14 || Karte == 15 || Karte == 16){
                                                Bank = 4 + Bank;
                                            }
                                            else if(Karte == 17 || Karte == 18 || Karte == 19 || Karte == 20){
                                                Bank = 5 + Bank;
                                            }
                                            else if(Karte == 21 || Karte == 22 || Karte == 23 || Karte == 24){
                                                Bank = 6 + Bank;
                                            }
                                            else if(Karte == 25 || Karte == 26 || Karte == 27 || Karte == 28){
                                                Bank = 7 + Bank;
                                            }
                                            else if(Karte == 29 || Karte == 30 || Karte == 31 || Karte == 32){
                                                Bank = 8 + Bank;
                                            }
                                            else if(Karte == 33 || Karte == 34 || Karte == 35 || Karte == 36){
                                                Bank = 9 + Bank;
                                            }
                                            else if(Karte == 37 || Karte == 38 || Karte == 39 || Karte == 40){
                                                Bank = 10 + Bank;
                                            }
                                            else if(Karte == 41 || Karte == 42 || Karte == 43 || Karte == 44){
                                                Bank = 10 + Bank;
                                            }
                                            else if(Karte == 45 || Karte == 46 || Karte == 47 || Karte == 48){
                                                Bank = 10 + Bank;
                                            }
                                            else if(Karte == 49 || Karte == 50 || Karte == 51 || Karte == 52){
                                                Bank = 10 + Bank;
                                            }             
                                        }
                                    }
                                }
                                if(eingabe2 == "k" || eingabe2 == "K"){
    
                                    Karte = (rand() % 13) + 1;
    
                                    if(Karte == 1 || Karte == 2 || Karte == 3 || Karte == 4){
                                        if(21 <= Spielerwert + 11){
                                            Spielerwert = 1 + Spielerwert;
                                        }
                                        else{
                                            Spielerwert = 11 + Spielerwert;
                                        }
    
                                    }
                                    else if(Karte == 5 || Karte == 6 || Karte == 7 || Karte == 8){
                                        Spielerwert = 2 + Spielerwert;
                                    }
                                    else if(Karte == 9 || Karte == 10 || Karte == 11 || Karte == 12){
                                        Spielerwert = 3 + Spielerwert;
                                    }
                                    else if(Karte == 13 || Karte == 14 || Karte == 15 || Karte == 16){
                                        Spielerwert = 4 + Spielerwert;
                                    }
                                    else if(Karte == 17 || Karte == 18 || Karte == 19 || Karte == 20){
                                        Spielerwert = 5 + Spielerwert;
                                    }
                                    else if(Karte == 21 || Karte == 22 || Karte == 23 || Karte == 24){
                                        Spielerwert = 6 + Spielerwert;
                                    }
                                    else if(Karte == 25 || Karte == 26 || Karte == 27 || Karte == 28){
                                        Spielerwert = 7 + Spielerwert;
                                    }
                                    else if(Karte == 29 || Karte == 30 || Karte == 31 || Karte == 32){
                                        Spielerwert = 8 + Spielerwert;
                                    }
                                    else if(Karte == 33 || Karte == 34 || Karte == 35 || Karte == 36){
                                        Spielerwert = 9 + Spielerwert;
                                    }
                                    else if(Karte == 37 || Karte == 38 || Karte == 39 || Karte == 40){
                                        Spielerwert = 10 + Spielerwert;
                                    }
                                    else if(Karte == 41 || Karte == 42 || Karte == 43 || Karte == 44){
                                        Spielerwert = 10 + Spielerwert;
                                    }
                                    else if(Karte == 45 || Karte == 46 || Karte == 47 || Karte == 48){
                                        Spielerwert = 10 + Spielerwert;
                                    }
                                    else if(Karte == 49 || Karte == 50 || Karte == 51 || Karte == 52){
                                        Spielerwert = 10 + Spielerwert;
                                    }                                                     
                                } 
                            } 
                        }   
                    }      
                }
            }
            if(Spiel == "P" || Spiel == "p" || Spiel == "Pferderennen"){
                        system("CLS");
                        cout << display <<endl;
                        cout << display2 <<endl;
                        cout << display3 <<endl;
                        cout << display4 <<endl;
                        cout << display5 <<endl;
                        cout << display6 <<endl;
                        cout << display7 <<endl;
                        int Pferdenummer;
                        int Gewinner;
                        string eingabe;
                        int i,u,z,t,r,e;
                        long long int Spielgeld;
                        i = 0;
                        while(i==0){
                            if(Kontostand == 0){
                    string Seele;
                    int Pleite;
                    int Pleite2;
                        cout << "Du bist Pleite, mochtest du russisches Roulette Spielen Um 10000 Coins zu gewinnen." <<endl;
                        cout << "Ja oder Nein?" <<endl;
                        cin >> Seele;
                        if(Seele == "J" || Seele == "j" || Seele == "Ja" || Seele == "ja" || Seele == "ja"){
                            Pleite = (rand() % 6) + 1;
                            Pleite2 = (rand() % 6) + 1;
                            if(Pleite == Pleite2){
                                 cout << "Du bist tot sorry" <<endl;
                                i++;
                                y++;
                            }
                            else{
                                cout << "Du hattest gluck hier hast du weitere 5000 Coins." <<endl;
                                Kontostand = Kontostand + 5000;
                                i++;
                            }
                        }
                        else if(Seele == "N"){
                            cout << "Schade war ein versuch wert." <<endl;
                            i++;
                            y++;
                        }
                        else{
                            cout << "Du laberst scheiße und bist tot" <<endl;
                            i++;
                            y++;
                        }
                    }
                            srand(time(0));
                            cout << "Du hast noch: " << Kontostand << " coins." <<endl;
                            cout << "Willst du eine Runde Spielen(S) oder willst du aufhoren(A)" <<endl;
                            cin >> eingabe;
                            if(eingabe == "A" || eingabe == "a"){
                                i++;
                            }       
                            if(eingabe == "S" || eingabe == "s"){
                                cout << "Mit wie vielen Coins willst du spielen?" <<endl;
                                cin >> Spielgeld;
                                while(u==0){
                                if(Spielgeld > Kontostand){
                                     cout << "So viel coins hast du nicht" <<endl;
                                    cout << "Deine Kontostand betragt: " << Kontostand << " coins"<<endl;
                                    cout << "Mit wie vielen Coins willst du spielen?" <<endl;
                                    cin >> Spielgeld;
                                }
                                else{
                                    u++;
                                    Kontostand = Kontostand - Spielgeld;
                                }
                            }
                            cout << "Auf welches Pferd willst du wetten? (1-6)" <<endl;
                            cin >> Pferdenummer;
    
                            Gewinner = (rand() % 6) + 1;
                                
                        if(Pferdenummer == Gewinner){
                            system("CLS");
                            cout << display <<endl;
                            cout << display2 <<endl;
                            cout << display3 <<endl;
                            cout << display4 <<endl;
                            cout << display5 <<endl;
                            cout << display6 <<endl;
                            cout << display7 <<endl;
                            cout << "Dein Pferd hat gewonnen" <<endl;
                            Kontostand = Kontostand + Spielgeld*2;
                        }
                        else{
                            system("CLS");
                            cout << display <<endl;
                            cout << display2 <<endl;
                            cout << display3 <<endl;
                            cout << display4 <<endl;
                            cout << display5 <<endl;
                            cout << display6 <<endl;
                            cout << display7 <<endl;
                            cout << "Du hast verloren, dass gewinner Pferd ist Nummer " << Gewinner <<endl;      
                        }
                    }
                }
            }
            if(Spiel == "R" || Spiel == "r" || Spiel == "Roulette"){
            int i, u, z, t, o;
            i = 0;
            long long int Spielgeld;
            string eingabe;
            int Gewinner;
            int tipp;
            string modus;
            string auswahl;
            string farbauswahl;
            system("CLS");
            cout << display <<endl;
            cout << display2 <<endl;
            cout << display3 <<endl;
            cout << display4 <<endl;
            cout << display5 <<endl;
            cout << display6 <<endl;
            cout << display7 <<endl;
    
    
            int schwarz[18] = {2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35};
            int rot[18] = {1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36};
    
                
                srand(time(0));
                while(i == 0){
                    if(Kontostand == 0){
                    string Seele;
                    int Pleite;
                    int Pleite2;
                        cout << "Du bist Pleite, mochtest du russisches Roulette Spielen Um 10000 Coins zu gewinnen." <<endl;
                        cout << "Ja oder Nein?" <<endl;
                        cin >> Seele;
                        if(Seele == "J" || Seele == "j" || Seele == "Ja" || Seele == "ja"){
                            Pleite = (rand() % 6) + 1;
                            Pleite2 = (rand() % 6) + 1;
                            if(Pleite == Pleite2){
                                 cout << "Du bist tot sorry" <<endl;
                                i++;
                                y++;
                            }
                            else{
                                cout << "Du hattest gluck hier hast du weitere 5000 Coins." <<endl;
                                Kontostand = Kontostand + 5000;
                                i++;
                            }
                        }
                        else if(Seele == "N"){
                            cout << "Schade war ein versuch wert." <<endl;
                            i++;
                            y++;
                        }
                        else{
                            cout << "Du laberst scheiße und bist tot" <<endl;
                            i++;
                            y++;
                        }
                    }
                    z = 0;
                    t = 0;
                    o = 0;
                    u = 0;
                    cout << "Du hast noch: " << Kontostand << " coins." <<endl;
                    cout << "Willst du eine Runde Spielen(S) oder willst du aufhoeren(A)" << endl;
                    cin >> eingabe;
                    if(eingabe == "A" || eingabe == "a"){
                        i++;
                    }
                    if(eingabe == "S" || eingabe == "s"){
                        cout << "Wieviel Coins willst du setzen?" << endl;
                        while(u == 0){
                            cin >> Spielgeld;
                            if(Spielgeld > Kontostand){
                                cout << "So viel Coins hast du nicht" <<endl;
                                cout << "Deine Kontostand lautet: " << Kontostand << " coins"<<endl;
                                cout << "Mit wie vielen Coins willst du spielen?" <<endl;
                            }
                            else{
                                u++;
                            }                     
                        }
                            cout << "Willst du auf eine Zahl setzen(Z), auf ungerade oder gerade(G) oder auf eine Farbe(F)?" << endl;
                            cin >> modus;
                            if(modus == "Z" || modus == "z"){
                                cout << "Auf welche Zahl willst du setzen?" << endl;
                                cin >> tipp;
                                Gewinner = (rand() % 37);
                                while(z == 0){
                                    if(tipp > 36 || tipp < 0){
                                        cout << "Deine Zahl ist zu groß! Es gibt nur 36 Zahlen" << endl;
                                        cout << "Auf welche Zahl willst du setzen?" << endl;
                                        cin >> tipp;
                                    }
                                    else{
                                        z++;
                                    }
                                }
                                if(tipp == Gewinner){
                                    system("CLS");
                                    cout << display <<endl;
                                    cout << display2 <<endl;
                                    cout << display3 <<endl;
                                    cout << display4 <<endl;
                                    cout << display5 <<endl;
                                    cout << display6 <<endl;
                                    cout << display7 <<endl;
                                    cout << " " <<endl;
                                    cout << "Du hast gewonnen! Die Kugel ist auf der " << Gewinner << " gelandet" << endl;
                                    Kontostand = Kontostand + Spielgeld*36;
                                }
                                else if(tipp != Gewinner){
                                    system("CLS");
                                    cout << display <<endl;
                                    cout << display2 <<endl;
                                    cout << display3 <<endl;
                                    cout << display4 <<endl;
                                    cout << display5 <<endl;
                                    cout << display6 <<endl;
                                    cout << display7 <<endl;
                                    cout << " " <<endl;
                                    cout << "Du hast verloren! Die Kugel ist auf der " << Gewinner << " gelandet" <<endl;
                                    Kontostand = Kontostand - Spielgeld;
                                }
                            }
                            else if(modus == "G" || modus == "g"){
                                cout << "Willst du auf ungerade(U) oder gerade(G) setzen?" << endl;
                                cin >> auswahl;
                                Gewinner = (rand() % 37);
                                while(t == 0){
                                    if(auswahl == "U" || auswahl == "u"){
                                        if(Gewinner % 2 == 1){
                                            system("CLS");
                                            cout << display <<endl;
                                            cout << display2 <<endl;
                                            cout << display3 <<endl;
                                            cout << display4 <<endl;
                                            cout << display5 <<endl;
                                            cout << display6 <<endl;
                                            cout << display7 <<endl;
                                            cout << " " <<endl;
                                            cout << "Du hast gewonnen! Die Kugel ist auf der " << Gewinner << " gelandet und ist ungerade!" << endl; 
                                            Kontostand = Kontostand + Spielgeld;
                                            t++;
                                        }
                                        else{
                                            system("CLS");
                                            cout << display <<endl;
                                            cout << display2 <<endl;
                                            cout << display3 <<endl;
                                            cout << display4 <<endl;
                                            cout << display5 <<endl;
                                            cout << display6 <<endl;
                                            cout << display7 <<endl;
                                            cout << " " <<endl;
                                            cout << "Du hast verloren! Die Kugel ist auf der " << Gewinner << " gelandet und ist gerade!" << endl;
                                            Kontostand = Kontostand - Spielgeld;
                                            t++;
                                        }
                                    }
                                    else if(auswahl == "G" || auswahl == "g"){
                                        if(Gewinner % 2 == 1){
                                            system("CLS");
                                            cout << display <<endl;
                                            cout << display2 <<endl;
                                            cout << display3 <<endl;
                                            cout << display4 <<endl;
                                            cout << display5 <<endl;
                                            cout << display6 <<endl;
                                            cout << display7 <<endl;
                                            cout << " " <<endl;
                                            cout << "Du hast verloren! Die Kugel ist auf der " << Gewinner << " gelandet und ist ungerade!" << endl;
                                            Kontostand = Kontostand - Spielgeld;
                                            t++;
                                        }
                                        else{
                                            system("CLS");
                                            cout << display <<endl;
                                            cout << display2 <<endl;
                                            cout << display3 <<endl;
                                            cout << display4 <<endl;
                                            cout << display5 <<endl;
                                            cout << display6 <<endl;
                                            cout << display7 <<endl;
                                            cout << " " <<endl;
                                            cout << "Du hast gewonnen! Die Kugel ist auf der " << Gewinner << " gelandet und ist gerade!" << endl;
                                            Kontostand = Kontostand + Spielgeld;
                                            t++;
                                        }
                                    }
                                }
                            }
                            else if(modus == "F" || modus == "f"){
                                cout << "Willst du auf Rot(R) oder auf Schwarz(S) setzen?" <<  endl;
                                cin >> farbauswahl;
                                Gewinner = (rand() % 37);
                                while(o == 0){
                                    if(farbauswahl == "R" || farbauswahl == "r"){
                                        if(Gewinner == 0){
                                            system("CLS");
                                            cout << display <<endl;
                                            cout << display2 <<endl;
                                            cout << display3 <<endl;
                                            cout << display4 <<endl;
                                            cout << display5 <<endl;
                                            cout << display6 <<endl;
                                            cout << display7 <<endl;
                                            cout << " " <<endl;
                                            cout << "Du hast verloren! Die Kugel ist auf der gruenen " << Gewinner << " gelandet" << endl;
                                            Kontostand = Kontostand - Spielgeld;
                                            o++;
                                        }
                                        else{
                                            for(int m = 1; m <= 18; m++){
                                            if(rot[m] == Gewinner){
                                                system("CLS");
                                                cout << display <<endl;
                                                cout << display2 <<endl;
                                                cout << display3 <<endl;
                                                cout << display4 <<endl;
                                                cout << display5 <<endl;
                                                cout << display6 <<endl;
                                                cout << display7 <<endl;
                                                cout << " " <<endl;
                                                cout << "Du hast gewonnen! Die Kugel ist auf einer roten " << Gewinner << " gelandet" << endl;
                                                Kontostand = Kontostand + Spielgeld;
                                                o++;
                                                }
                                            else if(schwarz[m] == Gewinner){
                                                system("CLS");
                                                cout << display <<endl;
                                                cout << display2 <<endl;
                                                cout << display3 <<endl;
                                                cout << display4 <<endl;
                                                cout << display5 <<endl;
                                                cout << display6 <<endl;
                                                cout << display7 <<endl;
                                                cout << " " <<endl;
                                                cout << "Du hast verloren! Die Kugel ist auf der schwarzen " << Gewinner << " gelandet" << endl;
                                                Kontostand = Kontostand - Spielgeld;
                                                o++;
                                                }
                                            }
                                        }
                                    }
                                
                                    else if(farbauswahl == "S" || farbauswahl == "s"){
                                        if(Gewinner == 0){
                                            system("CLS");
                                            cout << display <<endl;
                                            cout << display2 <<endl;
                                            cout << display3 <<endl;
                                            cout << display4 <<endl;
                                            cout << display5 <<endl;
                                            cout << display6 <<endl;
                                            cout << display7 <<endl;
                                            cout << " " <<endl;
                                            cout << "Du hast verloren! Die Kugel ist auf der gruenen " << Gewinner << " gelandet" << endl;
                                            o++;
                                        }
                                        else{
                                        for(int n = 1; n <= 18; n++){
                                            if(schwarz[n] == Gewinner){
                                                system("CLS");
                                                cout << display <<endl;
                                                cout << display2 <<endl;
                                                cout << display3 <<endl;
                                                cout << display4 <<endl;
                                                cout << display5 <<endl;
                                                cout << display6 <<endl;
                                                cout << display7 <<endl;
                                                cout << " " <<endl;
                                                cout << "Du hast gewonnen! Die Kugel ist auf einer schwarzen " << Gewinner << " gelandet" << endl;
                                                Kontostand = Kontostand + Spielgeld;
                                                o++;
                                            }
                                            else if(rot[n] == Gewinner){
                                                system("CLS");
                                                cout << display <<endl;
                                                cout << display2 <<endl;
                                                cout << display3 <<endl;
                                                cout << display4 <<endl;
                                                cout << display5 <<endl;
                                                cout << display6 <<endl;
                                                cout << display7 <<endl;
                                                cout << " " <<endl;
                                                cout << "Du hast verloren! Die Kugel ist auf der roten " << Gewinner << " gelandet" << endl;  
                                                Kontostand = Kontostand - Spielgeld;
                                                o++; 
                                            }
                                        }
                                    }
                                }
                                else{
                                    cout << "Eingabe falsch." << endl;
                                    o++;
                                }
                            }     
                        }
                    }
                }       
            }
        }
    }


  • @HorstMaster

    Wenn du dir keine Mühe beim Fragen gibst, wieso sollten andere sich bemühen dir zu antworten?



  • wo brauchst du hilfe? ich habe das gleiche programm mit den selben fehlern. Guter Programmierstil 👍



  • @MadCookie sagte in Brauche Hilfe bei Pferderennen:

    ...
    Guter Programmierstil 👍

    Äh.... nein. Ziemlich mies sogar, aber darum kann man sich kümmern, wenn das Programm funktioniert. D.h., wenn man dann noch möchte und man Programmieren in C++ nicht als Fire-and-Forget Kurs betrachtet.



  • @DocShoe Also ich finde es gut, man muss ja nicht direkt so klugscheißen. Das Programm tut ja was es soll. Man muss ja nicht direkt Profi-Programmierer sein 🖕🏿 ☮



  • @DocShoe ist geändert.



  • @MadCookie Entschuldigung das sollte kein 🖕🏿 sein, sondern ein 👍



  • @DocShoe Kannst du helfen ein richtig funktionierendes Programm zu schreiben?



  • Hallo @HorstMaster ,
    bevor Du Dich an einem Spiel versuchst, schau doch mal nach, was eine Funktion ist und warum es diese gibt.
    Man könnte nur mal zum Anfang die Anzeige von CASINO in eine Funktion auslagern; würde Deinen Sourcecode schon mal um einen hohen Faktor verkürzen und damit lesbarer machen.
    Dementsprechend könnte jedes Spiel angegangen werden.
    Später, wenn Du noch Interesse an Programmieren mit C++ hast, könntest Du Dich ggf. mit der objektorientierten Programmierung beschäftigen. C++ ist dafür gemacht.



    1. y ist nicht initialisiert, d.h. die Überprüfung auf 0 in Zeile 24 ist alleine schon Glücksspiel
    2. du solltest den RNG nur ein Mal initialisieren, im Moment tust du das mehrmals in der while-Schleife in Zeile 62. Und Zeile 526. Und vielleicht noch öfter, hab nicht drauf geachtet
    3. die ganze Funktionalität in einer Funktion zu implementieren ist... schlecht. Unterteil´ das Programm in verschiedene Aufgaben und lasse jede Aufgabe in einer Funktion lösen. Als Faustregel sagt man, dass eine Funktion nur in Ausnahmefällen länger als eine Bildschirmseite sein sollte.

    Edit:
    Ja, wir können dir helfen. Dann solltest du allerdings auch Initiative zeigen und auf Ratschläge hören. Der Weg von diesem Spaghetticode zu einem sauberen C++ Programm ist lang.
    C++ ist eine Multiparadigmen-Sprache, wenn du dich gegen einen objektorientierten Ansatz entscheidest ist das auch ok.



  • @HorstMaster

    Dein Code ist kein guter Programmierstil, da

    • deine main() Funktion über 800 Zeilen groß ist.
    • du eine Schachteltiefe von 8 hast.
    • du Funktionalitäten nicht in Klassen und Funktionen unterteilt hast.
    • dadurch deine main() Funktion eine eierlegende Wollmilchsau ist.
    • jede Menge Kommentare fehlen

    Und die Hauptfrage hast du nicht beantwortet: Was ist denn die Wahrscheinlichkeit der einzelnen Pferde?

    Oder möchtest du ein Pferderennen simulieren? So ein Pferd hat doch eine Menge von Eigenschaften welche starken Einfluss auf seine Siegchancen hat. Dadurch entsteht doch die Klasse der Favoriten, welche ein Rennen eher gewinnt als ein Außenseiter. Die Chancen auf einen Sieg eines Pferdes sind also nicht gleichverteilt, sondern eher normalverteilt (hust "Wiki ist dein Freund")



  • @DocShoe: y ist eine globale Variable, also (ohne explizite Initialisierung) mit dem Standardwert 0 initialisiert.

    Der Code erinnert mich an meine ersten BASIC-Programme, wo ich auch noch keine Subroutinen und Arrays kannte.



  • @Th69 sagte in Brauche Hilfe bei Pferderennen:

    @DocShoe: y ist eine globale Variable, also (ohne explizite Initialisierung) mit dem Standardwert 0 initialisiert.

    Der Code erinnert mich an meine ersten BASIC-Programme, wo ich auch noch keine Subroutinen und Arrays kannte.

    Puh, man lernt bei C++ echt nicht aus. Warum überrascht mich die Sprache immer wieder? Ich hab den Eindruck, dass das Kommittee trollt und sich heimlich drüber kaputtlacht... für jeden Mist gibt´s Sonderregeln und Ausnahmen.



  • @MadCookie
    Wie ich sehe, hast Du in der Zwischenzeit einen Deutsch-Kurs gemacht.
    Herzlichen Glückwunsch!



  • @Quiche-Lorraine Kannst du mir das zeigen wie ich aus der main-Funktion, dann auf die Blackjack-Funktion zugreife? Mein Lehrer hat uns halt beigebracht das man am besten alles ins Main Programm reinschreiben soll.



  • Das ist auch schon in C so - und der technische Grund ist, daß die globalen Variablen im .data-Bereich der Anwendung abgelegt werden (und [sinnvollerweise] mit Nullen, bzw. genauer: einer Null-Bytefolge, initialisiert werden) und dieser wird dann beim Laden der Anwendung (d.h. beim Erzeugen des Prozesses) in den Hauptspeicher gemappt, s.a. PE-Format: Special Sections oder als Überblick Section Names.

    Für andere Executable/Object-Formate gilt ähnliches.

    Lokale Variablen dagegen werden ja (üblicherweise) auf dem Stack abgelegt und wenn nicht initialisiert, einfach der Stackpointer verändert (so daß dann ein "zufälliger"-Wert dort drin steht).

    Edit:
    @HorstMaster: s. z.B. C++-Programmierung/ Weitere Grundelemente/ Prozeduren und Funktionen (Stichwort: Aufruf).
    So schlecht kann kein Programmierer-Lehrer sein!?! Kann es sein, daß du das eher mißverstanden hast? Alle Funktionen müssen (zumindestens indirekt) über die main-Funktion aufgerufen werden, ansonsten werden sie niemals ausgeführt.


Anmelden zum Antworten