By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

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

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.  
  9.   string gamemode,pacanele="Pacanele",blackjack="Blackjack";
  10.     float i=0,credit=100,c1=0,a;
  11.     cout<<"Bun venit la cazino!"<<endl;
  12.     cout<<"Alege un mod de joc:"<<pacanele<<endl;
  13.     cout<<blackjack;cin>>gamemode;
  14.     if(gamemode==pacanele){
  15.         srand(time(0));
  16.         while(i++ < 3){
  17.             unsigned int r = (rand()%10)-1;
  18.             cout<<r<<" "<<endl;
  19.             credit=credit-3.33;
  20.             if(i==1){
  21.                 c1=1;
  22.                 a=r;
  23.             }
  24.             if(a==r&&i>1)
  25.                 c1++;
  26.         if(c1>1&&a==r)
  27.                 credit=credit+10;
  28.         if(c1==3)
  29.                 credit=credit*10;
  30.         }
  31.     }
  32.     cout<<"Your credit is:"<<credit;
  33.     int x,d,s=0,s1=0,credits1=1000;
  34.     if(gamemode==blackjack){
  35.         srand((int)time(0));
  36.         while(i++ < 1){
  37.             unsigned int d = (rand()%20)+1;
  38.             cout<<d<<" "<<endl;
  39.             s=s+d;
  40.         }
  41.         while(i++ < 1){
  42.             unsigned int x = (rand()%20)+1;
  43.             cout<<x<<" "<<endl;
  44.             s1=s1+x;
  45.         }
  46.         while(i++ < 1){
  47.             unsigned int d = (rand()%20)+1;
  48.             cout<<d<<" "<<endl;
  49.             s=s+d;
  50.         }
  51.         while(i++ < 1){
  52.             unsigned int x = (rand()%20)+1;
  53.             cout<<x<<" "<<endl;
  54.             s1=s1+x;
  55.         }
  56.         while(i++ < 1){
  57.             unsigned int d = (rand()%20)+1;
  58.             cout<<d<<" "<<endl;
  59.             s=s+d;
  60.         }
  61.         while(i++ < 1){
  62.             unsigned int x = (rand()%20)+1;
  63.             cout<<x<<" "<<endl;
  64.             s1=s1+x;
  65.         }
  66.          if(s1>s)
  67.             credits1=credits1+100;
  68.          if(s>s1)
  69.             credits1=credits1-100;
  70.     }
  71.     return 0;
  72. }
  73.  
  74. /*basicaly i'm making a roulette and blackjack like at 
  75. the casino and i need help*/
2 Weeks Ago #1
Share this Question
Share on Google+
3 Replies


dev7060
Expert 100+
P: 183
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?
2 Weeks Ago #2

Expert 100+
P: 2,402
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;).
2 Weeks Ago #3

rollerbladegirl
P: 69
What if you tried it like this:

Expand|Select|Wrap|Line Numbers
  1.     if(gamemode==blackjack){
  2.         srand((int)time(0));
  3.  
  4.         while(i++ < 1){
  5.  
  6.             unsigned int d
  7.             unsigned int x
  8.  
  9.             int d = (rand()%20)+1;
  10.             cout<<d<<" "<<endl;
  11.             s=s+d;
  12.  
  13.             int x = (rand()%20)+1;
  14.             cout<<x<<" "<<endl;
  15.             s1=s1+x;
  16.  
  17.             int d = (rand()%20)+1;
  18.             cout<<d<<" "<<endl;
  19.             s=s+d;
  20.  
  21.             int x = (rand()%20)+1;
  22.             cout<<x<<" "<<endl;
  23.             s1=s1+x;
  24.  
  25.             int d = (rand()%20)+1;
  26.             cout<<d<<" "<<endl;
  27.             s=s+d;
  28.  
  29.             int x = (rand()%20)+1;
  30.             cout<<x<<" "<<endl;
  31.             s1=s1+x;
  32.  
  33.         }
  34.  
  35.          if(s1>s)
  36.             credits1=credits1+100;
  37.          if(s>s1)
  38.             credits1=credits1-100;
  39.     }
  40.     return 0;
1 Week Ago #4

Post your reply

Sign in to post your reply or Sign up for a free account.