I need help with my algorythm because i've tried evrything

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bruhmoment05
    New Member
    • Feb 2020
    • 1

    I need help with my algorythm because i've tried evrything

    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <time.h>
    
    using namespace std;
    
    int main(){
     
      string gamemode,pacanele="Pacanele",blackjack="Blackjack";
        float i=0,credit=100,c1=0,a;
        cout<<"Bun venit la cazino!"<<endl;
    	cout<<"Alege un mod de joc:"<<pacanele<<endl;
    	cout<<blackjack;cin>>gamemode;
    	if(gamemode==pacanele){
            srand(time(0));
            while(i++ < 3){
                unsigned int r = (rand()%10)-1;
                cout<<r<<" "<<endl;
                credit=credit-3.33;
                if(i==1){
                    c1=1;
                    a=r;
                }
                if(a==r&&i>1)
                    c1++;
            if(c1>1&&a==r)
                    credit=credit+10;
            if(c1==3)
                    credit=credit*10;
            }
    	}
    	cout<<"Your credit is:"<<credit;
    	int x,d,s=0,s1=0,credits1=1000;
    	if(gamemode==blackjack){
            srand((int)time(0));
            while(i++ < 1){
                unsigned int d = (rand()%20)+1;
                cout<<d<<" "<<endl;
                s=s+d;
            }
            while(i++ < 1){
                unsigned int x = (rand()%20)+1;
                cout<<x<<" "<<endl;
                s1=s1+x;
            }
            while(i++ < 1){
                unsigned int d = (rand()%20)+1;
                cout<<d<<" "<<endl;
                s=s+d;
            }
            while(i++ < 1){
                unsigned int x = (rand()%20)+1;
                cout<<x<<" "<<endl;
                s1=s1+x;
            }
            while(i++ < 1){
                unsigned int d = (rand()%20)+1;
                cout<<d<<" "<<endl;
                s=s+d;
            }
            while(i++ < 1){
                unsigned int x = (rand()%20)+1;
                cout<<x<<" "<<endl;
                s1=s1+x;
            }
             if(s1>s)
                credits1=credits1+100;
             if(s>s1)
                credits1=credits1-100;
    	}
    	return 0;
    }
    
    /*basicaly i'm making a roulette and blackjack like at 
    the casino and i need help*/
    Last edited by gits; Feb 10 '20, 12:32 PM. Reason: added code tags
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 655

    #2
    I need help with my algorythm because i've tried evrything
    basicaly i'm making a roulette and blackjack like at
    the casino and i need help
    What kind of help is needed here? What exactly is not working?

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      For gamemode == blackjack, I see a sequence of while(i++<1) blocks. Only the first of these will be executed, the following ones will be skipped. Maybe you want these blocks to be for(i=0; i++<1;).

      Comment

      • rollerbladegirl
        New Member
        • Jan 2020
        • 69

        #4
        What if you tried it like this:

        Code:
            if(gamemode==blackjack){
                srand((int)time(0));
        
                while(i++ < 1){
        
                    unsigned int d
                    unsigned int x
        
                    int d = (rand()%20)+1;
                    cout<<d<<" "<<endl;
                    s=s+d;
        
                    int x = (rand()%20)+1;
                    cout<<x<<" "<<endl;
                    s1=s1+x;
        
                    int d = (rand()%20)+1;
                    cout<<d<<" "<<endl;
                    s=s+d;
        
                    int x = (rand()%20)+1;
                    cout<<x<<" "<<endl;
                    s1=s1+x;
        
                    int d = (rand()%20)+1;
                    cout<<d<<" "<<endl;
                    s=s+d;
        
                    int x = (rand()%20)+1;
                    cout<<x<<" "<<endl;
                    s1=s1+x;
        
                }
        
                 if(s1>s)
                    credits1=credits1+100;
                 if(s>s1)
                    credits1=credits1-100;
            }
            return 0;
        Last edited by rollerbladegirl; Feb 16 '20, 01:16 AM. Reason: I gave an option that was wrong. I removed it.

        Comment

        Working...