473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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*/
Feb 5 '20 #1
3 2451
dev7060
636 Expert 512MB
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?
Feb 6 '20 #2
donbock
2,426 Expert 2GB
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;).
Feb 10 '20 #3
rollerbladegirl
69 64KB
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;
Feb 14 '20 #4

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

Similar topics

9
by: Darren | last post by:
Hi wondering if anyone can help. What i'm trying to do is get a company from a MSSQL database with the COMPANYNO which is a 'uniqueidentifier'. Then with this COMPANYNO I want to reference it to...
7
by: i_vincent | last post by:
Hi all, Newbie Python programmer here, so please be patient. I have spent all day googling for an answer to my problem, but everything I try fails to work (or works from the Interpreter with a...
0
by: Adam Haskell | last post by:
Ok heres the situation: We have a linked server from SQL 2000 to a foxpro dbf. In our test enviroment we had the Foxpro and SQL server on the same machine. The linked worked perfect. Now we are...
1
by: Srinivasa Ra via .NET 247 | last post by:
(Type your message here) I am writing an application that does lot of read/write's withcomputer's serial port. The application as a whole is workingfine. Current Approach: I have a Timer that...
25
by: Mark | last post by:
I'm just starting out in an introductory ASP.Net course, and am trying to run a simple program but keeping getting an error. I'm running XP, have installed Internet Information Services (5.1) ,...
1
by: Arvind P Rangan | last post by:
Hi, I have created a class library which i need to use in my ASPX file. when i say: Dim mylib As TestLib = new TestLib() it gives me an error saying type required. How do we use a class...
0
by: saravanan_article | last post by:
Hi I am newbie to C#, i am using C# 2005 and DataGridView in my Application. The problem is described here I am using DataGrid and I placed some Headers like Column1,Column2,Column3.... What i...
9
by: Michele 'xjp' | last post by:
Hi there. I have some problems with cin. Here's the code: http://rafb.net/p/GhK3AU65.html If you press '6', and 'enter', it will have to ask for another insert of a string. However, in this...
8
by: rdabane | last post by:
I'm trying to perform following type of operation from inside a python script. 1. Open an application shell (basically a tcl ) 2. Run some commands on that shell and get outputs from each command...
1
by: brendanmcdonagh | last post by:
Hi all, I have my little message program working until i press a button and then it'll go to actionPerformed method, and stop reading but will keep sending a message which is being received....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.