Chubab
Messages postés11Date d'inscriptionmardi 6 décembre 2005StatutMembreDernière intervention19 mai 2009
-
16 févr. 2006 à 16:02
bayeto
Messages postés224Date d'inscriptionmardi 12 août 2003StatutMembreDernière intervention18 octobre 2010
-
16 févr. 2006 à 21:28
voila je suis en train de créer un programme qui donne les probabilités au hold'em poker...
kan jutilise cin pour une variable char il ne prend que le premier charactere (si jen entre plus quun)...cela me va, mon programme gere ceci (arrive ds le cas de la carte 10)
le probleme est le prochain cin est automatique assigner la valeur 0 dans ce cas...je suis capable de gérer ce probleme...mais jaimerais savoir qcq je pourrais faire pour quil ne fasse pas cela...
MERCI,
CHUBAB
PS: désolez pour le code en anglais....
//poker.cpp
//this programs tells you the possibilities you have to get all kind of hands at hold'em poker
#include
using namespace std;
#include <conio.h>
#include
//function declaration
int getcv(char);
int getct(char);
void main()
{
char cardt; //use to get the type of card before changing it to integer
char cardv; //use to get the card value before changing it to integer
int ct[7]; //variable containing the type of the seven cards (1=Spade, 2=Hearth, 3=Club, 4=Diamond)
int cv[7]; //variable contaning the value of the seven cards (from 2 to ace)
//get the value and type of the first two cards and change it to integer value
cout << "This programs tells you the possibilities you have in hold'em poker as the game goes on!!\n";
cout << "Enter the type of the first card (S,H,C,D):";
cin >>cardt;
ct[1] = getct(cardt);
cout << "Enter the value of the first card(2-A):";
cin >>cardv;
cv[1] = getcv(cardv);
cout << "Enter the type of the second card (S,H,C,D):";
cin >>cardt;
ct[2] = getct(cardt);
cout << "Enter the value of the second card(2-A):";
cin >>cardv;
cv[2] = getcv(cardv);
//this function goes through all the possible values for val and assign it the corresponding int
int getcv(char cval)
{
int cv;
if(cval=='A')
cv=14;
else if(cval=='a')
cv=14;
else if(cval=='K')
cv=13;
else if(cval=='k')
cv=13;
else if(cval=='Q')
cv=12;
else if(cval=='q')
cv=12;
else if(cval=='J')
cv=11;
else if(cval=='j')
cv=11;
else if(cval=='1')
cv=10; //because the if the user enters 10 as the value the char variable is gonna take only the 1...
else
cv=(static_cast(cval))-48; //if val is not A,K,Q,J its a number from 2 to 10!...in ascii 0 is 48 so remove 48 from the char value
return(cv);
}
//this function goes through the 4 possible type value and converts it to the int format
int getct(char ctyp)
{
int ct;
if(ctyp=='0') //if ctyp gets value 0 user is reasked for it
cin >> ctyp;