Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Little Help.

Status
Not open for further replies.

Sacreddruid

Programmer
Joined
Jun 8, 2003
Messages
1
Location
US
Can anyone point me in the direction of a good example of a really really basic C++ blackjack, Nothing fancy, just really really basic commands.
I'm not using anyhting beyond

#include<iostream.h>
#include<iomanip.h>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<fstream.h>
#include<time.h>
#include<stdlib.h>

As of now, and I'd prefer not to have to learn too much new stuff to get this done.

Thanks.

~Squall
 
I suggest an array of size 52 where each number describes a card and suit. Make the aces 0-3 and so on. Aces can be 11 or 1, face cards and 10s are treated as 10, etc. Make a shuffle function implimenting rand() and at the beginning of the prog do an srand(time(NULL)); Then swap the array values by generating 2 random numbers from 0-51 or rand()%52; swap using a for loop of a minimum number of swaps = 100. Make a function to add up the current hand. Prompt the user if they want a hit or want to stay. Also impliment splits. That should get you started.

Sorry for the brain dump. I wrote a similar prog in college. This was my approach. Later we implimented a card class which returned the value of the card. A class to impliment the dealing etc... That will come later.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top