Προς το περιεχόμενο

BLACK JACK IN C


vardiabasis

Προτεινόμενες αναρτήσεις

Δημοσ.

Loipon paidakia xreiazomai ti bohthia sas gia ena programmataki se C,me to opoio ta exw vrei skoyra.To programma exei ws e3hs:Prokeitai gia ena paihnidi black jack,me kapoies paralages vevaia.Oi kanones toy einai:

* 3 paihtes (2CPU kai 1 user).

* kathe paixths exei 300euro.

* paizoyn ola ta fila.

* epilogh gia ton asso na metraei pote gia 1 kai pote gia 11(an yparhoyn 2 assoi o enas metraei gia 1 kai o allos 11).

* To paixnidi teleiwnei otan enas paixths mazepsei 900euro ( h otan oloi oi alloi hasoyn ta lefta toys).

* h mana orizetai sthn arhh toy painidioy kai einai aytos pou sthn diadikasia travhgmatos 1 filoy apo kaue paikth ua exei to megalytero(h mana allazei ,otan kaeio sygkekrimenos paikths,aristerostofa).

* yparxei elaxisto pontarisma 20euro

* anakatema kai filwn sthn arxh toy paihnidiou kai se kathe kainourio gyro.

* otan arxizei to paixnidi h mana moirazei ena xarti se kathe pakth arxizontas apo ton eayto ths,sth synexeia pairnei ayth osa xartia thelei mexri na stamathsei h na kaei,ginontai ta pontarismata kai moirazei xartia stous dyo allous mexri na kaoun h na stamathsoyn kai sto telos ginetai h sygkrish kai allazoun xeri ta lefta.

* stis isopalies kerdizei h mana.

 

 

 

Δημοσ.

Δεν θελω να φανω κακος..αλλα αν δεν γινεις συγκεκριμενος σε καποιο ιδιατερο προβλημα δεν νομιζω να υπαρξει βοηθεια απο εδώ. Διαβαζοντας το ποστ..τωρα ο οποιοσδηποτε, περιμενεις να σου αραδιασει τον κωδικα? τον αλγοριθμο?

 

no offense

 

Δημοσ.

Και πόσα δίνεις γι'αυτο;;;

 

Γιατί αν κατάλαβα καλά ζητάς να στο κάνουμε, όχι να σε βοηθήσουμε κάπου που έχεις πρόβλημα. <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/wink.gif" alt="" />

 

Και τώρα που το παρατηρώ:

 

Loipon paidakia xreiazomai ti bohthia sas gia ena programmataki se C,me to opoio ta exw vrei skoyra.To programma exei ws e3hs:Prokeitai gia ena paihnidi black jack,me kapoies paralages vevaia.Oi kanones toy einai:

 

Πρώτη φορά μπαίνεις, δεν λές ούτε ενα Γεια, ούτε ένα ευχαριστώ στο τέλος και έχεις και την απαίτηση να σου γράψουμε ολόκληρο το πρόγραμμα.

 

no offence και εγώ.... <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/tongue.gif" alt="" /> <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/tongue.gif" alt="" /> <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/tongue.gif" alt="" /> <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/tongue.gif" alt="" />

Δημοσ.

Ftiaxe mia stoiva - gemisetin me ta fila.

3 struct -1 gia kathe paikti) pou na exoun ta stoixeia tous ($$ kai oti allo xreiazetai.

 

while (TRUE)

{

kodikas edo

}

 

mia function pou na elkenxei an to paixnidi teleiose

ta alla einai eukola <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/tongue.gif" alt="" />

Δημοσ.

h alh8eia einai oti hmoun ligo agenhs kai gia auto zhtaw sygnwmh.alla exw poly ligo kairo poy exw asxolh8ei me th C kai ayto to programma,to opoio prohl8e apo to daskalo plhroforikhs sto sxoleio moy an kai den kanoyme C alla Pascal,me pelagwse.

OXI denh8ela se kamia periptwsh na moy steilete ton kwdika etoimo,ayto htan dikh moy paralhpsh,alla ena "mpoysoyla(algori8mo)" panw ston opoio na kinh8w.

 

 

Oson afora ta lefta,anarwtiemai an zhtate xrhmata gia ena toso fainomenika eykolo programma,ti 8a zhtagate an sas ane8etan mia sovarh doyleia?...

Egw an hmoyn empeiros programmatisths den 8a katadexomoyn na parw xrhmata.

 

EYXARISTW prokatavolika...

Δημοσ.

Katarxin,prepei na ftacseis procedure pou na paragei

tin trapoula anakatemeni ka8e fora.Sou dinw mia idea se psevdokwdika sxetika me afto:

n:=0;

flag:=1;

Epanelave

x:=tyxaios ari8mos apo 2 ews 14 ;

(yparxei etoimi

synartisi stin C pou paragei tyxaious ari8mous kai mporeis na oriseis esy to dianisma alla den 8ymamai poia...)

Metatropi tou X apo akeraio se xaraktira;

(Episis yparxei etoimh synartisi stin C pou den 8ymamai <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/frown.gif" alt="" />);

 

Gia I:= 1 mexri n kane

An x=stack tote k:=k+1;

telos_gia

An k>4 tote flag:=0;

alliws flag:=1;

 

An flag=1 tote

n:=n+1;

An x='11' tote x:='J';

An x='12' tote x:='Q';

An x='13' tote x:='K';

An x='14' tote x:='A';

stack[n]:=x;

telos_an

mexri n=52;

 

Kapws etsi prepei na pigenei gia tin dimourgia tis trapoulas.Pantws dokimase na tin kaneis stin pascal,8a sou fainetai pio aplo.Elpizw na voi8isa estw ligo.:)

Mou fainetai periergo... Kanete toso polyploka sto sxoleio sas? Mpravo,ecsyxronismos!:P

Δημοσ.
monster

said:

Oson afora ta lefta,anarwtiemai an zhtate xrhmata gia ena toso fainomenika eykolo programma,ti 8a zhtagate an sas ane8etan mia sovarh doyleia?...

Egw an hmoyn empeiros programmatisths den 8a katadexomoyn na parw xrhmata.

 

EYXARISTW prokatavolika...

 

Βρε σύ......τα χρήματα ήταν αστείο.

 

Κάθε τρείς καί λίγο μπαίνει κάποιος και ζητάει να του φτιάξουν ολόκληρο πρόγραμμα, η την εργασία που έχει στο excel. Για ποιο λόγο κάποιος να ενδιαφερθεί;;;;

 

Δώσε μου κίνητρο, ζήτα μου κάτι που θα ενδιαφερθώ να το κάνω και θα σε βοηθήσω πίστεψε με.

 

Τα παιδιά παραπάνω σου έδωσαν μια γενική ιδέα πώς να το κάνεις πιστεύω οτι θα σε βοηθήσει.

 

 

Δημοσ.

Loipon paidia mexri twra exw kanei 1 pinaka int cards[52][2],

ton opoio exw skopo na ton na gemisw sth prwth sthlh me

ta noymera twn kartwn [1,2,3,4,5,6,7,8,9,10,10(j),10(q),10(k)]*4

kai sth diplanh sthlh 13 3aria,13 4aria,13 5aria kai 13 6aria,

me skopo sthn ektypwsh na exw kati san ayto:p.x.

printf("%d of %c",*(*(cards+6)),*(*(cards+6)+1));

kai na moy ektypwsei 7 of hearts(opoy hearts to symvolo toys).

sth synexeia exw ftia3ei mia synarthsh me thn opoia anakatevw ton

pinaka pernontas san zeygari ta stoixeia poy briskontai sthn idia

grammh.h sygkekrimenh synarthsh pernei ena ari8mo apo mia 8esh

toy pinaka kai ton enalasei me ton ari8mo sth 8esh 52--;

telos exw ftia3ei mia trith synarthsh me thn opoia sthn arxh toy pexnidioy

travaei o ka8e paikths fyllo me skopo opoios exei to pio megalo na

ginei mana[drawcard()].

to provlhma einai sto oti den 3erw giati o pinakas cards[][] den gemizei

me th synarthsh suffle2() para paramenoyn ola toy ta stoixeia 0.

akoma 8elw otan travane karta oi paiktes na fainetai J of clubs(symvolo)

h k of hearts(symvolo),pragma to opoio symfona me th dia ta3h toy pinaka

einai adynato.

skeftomai meta to anakatema twn fyllwn na ta peta3w se mia lista h stoiva

gia na mporw otan travaw ena harti na mh moy 3anaerhetai,mporei na ginei

ayto h 8a moy dhmioyrghsei alla problhmata meta oson afora th diaxhrhsh

twn hartiwn?

 

 

 

APO KATW SAS PARA8ETW TON KWDIKA POY EXW GRAPSEI MEXRI STIGMHS:

 

#include <stdio.h>

#include <conio.h>

#include <math.h>

#include <stdlib.h>

#include <process.h>

#include <time.h>

 

int USER=0;

int CPU1=0;

int CPU2=0;

 

 

int cards[52][2];

 

 

 

void info();

void suffle();

void suffle2();

void drawcard();

 

 

 

 

 

 

 

 

void main()

 

{

 

char ch;

int i;

 

 

printf("\t\t ::WELCOME TO BLACK JACK GAME::\n\n\n");

 

printf("Some useful infomation:\n\n");

printf(" *You have 1000 EURO\n");

printf(" *Your maximum bet is 500 EURO\n");

printf(" *Your minimum bet is 50 EURO\n\n\n");

printf("PRESS 'y' TO PLAY BLACK JACK AND 'n' TO SEE MORE INFO\n");

 

 

 

ch=getch();

 

if(ch=='n')

 

info();

 

if(ch=='y')

 

{

 

void shuffle2();

void shuffle();

 

 

for(i=0;i<52;i++)

printf("%d",*(*(cards+i)+1));

 

printf("\n\nPRESS 'd' TO SEE WHO DEALS");

ch=getch();

 

if (ch=='d')

 

 

drawcard();

 

 

}

 

}

 

 

 

void drawcard()

 

{

char ch;

 

 

CPU1 = *(*(cards+0)+0);

 

printf("\nCPU1 has %d of %c\n",*(*(cards+0)+0),*(*(cards+0)+1));

 

CPU2 = *(*(cards+1)+0);

 

printf("CPU2 has %d of %c\n\n",*(*(cards+1)+0),*(*(cards+1)+1));

 

printf("Press 'd' to draw a card\n");

ch=getch();

if (ch=='d')

{

USER = *(*(cards+2)+0);

printf("You have %d of %c\n",*(*(cards+2)+0),*(*(cards+2)+1));

}

 

if (CPU1>CPU2)

 

 

{

if (CPU1>USER)

printf("CPU1 will be the dealer\n");

if (USER>CPU1)

printf("You will be the dealer\n");

}

 

if (CPU2>CPU1)

 

 

{

 

if(CPU2>USER)

printf("CPU2 will be the dealer\n");

if (USER>CPU2)

printf("You will be the dealer\n");

 

}

 

}

 

 

 

 

 

 

 

void shuffle() //shuffles the arrays into a random order

 

{

 

int j,k;

int temp[52][2];

srand((unsigned) time(NULL)); //Seeds rand()

 

j = 52;

while(j > 0) //algorithm that puts the card values and names in random order

{

k = rand() % j +1; //set k to a random # between 1 and the current value of j

 

*(*(temp+j)+0) = *(*(cards+j)+0);

*(*(temp+j)+1) = *(*(cards+j)+1);

 

 

*(*(cards+j)+0) = *(*(cards+k)+0);

*(*(cards+j)+1) = *(*(cards+k)+1);

 

 

*(*(cards+k)+0) = *(*(temp+j)+0);

*(*(cards+k)+1) = *(*(temp+j)+1);

 

 

j--;

}

 

 

 

}

 

 

 

 

 

void shuffle2() //fills 52 card array with values of cards

 

{

int index, l;

 

//Spades

for(index=1; index<=10; index++) //Fills an array with values of the cards Ace-10. Here Ace is 1.

{

*(*(cards+index)+0)=index;

*(*(cards+index)+1)=6;

}

 

*(*(cards+11)+0)='J'; //Values for Jack Queen King

*(*(cards+12)+0)='Q';

*(*(cards+13)+0)='K';

*(*(cards+11)+1)=6;

*(*(cards+12)+1)=6;

*(*(cards+13)+1)=6;

 

l=1;

//Hearts

for(index=14; index<=23; index++) //Fills an array with values of the cards Ace-10. Here Ace is 1.

{

 

*(*(cards+index)+0)=l;

*(*(cards+index)+1)=3;

 

l++;

}

 

*(*(cards+24)+0)='J'; //Values for Jack Queen King

*(*(cards+25)+0)='Q';

*(*(cards+26)+0)='K';

*(*(cards+24)+1)=3;

*(*(cards+25)+1)=3;

*(*(cards+26)+1)=3;

 

l=1;

//Clubs

for(index=27; index<=36; index++) //Fills an array with values of the cards Ace-10. Here Ace is 1.

{

*(*(cards+index)+0)=l;

*(*(cards+index)+1)=5;

l++;

}

 

*(*(cards+37)+0)='J'; //Values for Jack Queen King

*(*(cards+38)+0)='Q';

*(*(cards+39)+0)='K';

*(*(cards+37)+1)=5;

*(*(cards+38)+1)=5;

*(*(cards+39)+1)=5;

 

l=1;

//Diamonds

for(index=40; index<=49; index++) //Fills an array with values of the cards Ace-10. Here Ace is 1.

{

*(*(cards+index)+0)=l;

*(*(cards+index)+1)=4;

l++;

}

 

*(*(cards+50)+0)='J'; //Values for Jack Queen King

*(*(cards+51)+0)='Q';

*(*(cards+52)+0)='K';

*(*(cards+50)+1)=4;

*(*(cards+51)+1)=4;

*(*(cards+52)+1)=4;

}

 

 

 

 

 

 

 

void info() //displays the rules of blackjack

{

char ch;

 

system("cls");

 

printf("Here are the rules:\n");

printf("A natural 21 means an automatic win.\n");

printf("\n");

printf("The game is played with a standard 52 card deck. \n");

printf("The deck re-shuffles after 52 cards have been dealt.\n");

printf("There is no doubling down or other complications.\n");

printf("J,Q,K all count as 10. An Ace can count as an 11 or a 1.\n");

printf("\n");

printf("Press 'y' to play BlackJack ");

ch=getch();

 

 

while(ch!='y')

{

system("cls");

 

printf("\n");

printf("Sorry that was not an option. Please try again.\n");

printf("\n");

printf("Here are the rules:\n");

printf("A natural 21 means an automatic win.\n");

printf("\n");

printf("The game is played with a standard 52 card deck. \n");

printf("The deck re-shuffles after 52 cards have been dealt.\n");

printf("J,Q,K all count as 10. An Ace can count as an 11 or a 1.\n");

printf("\n");

printf("Press 'y' to play BlackJack ");

ch=getch();

}

 

 

system("cls");

shuffle();

 

 

}

 

Δημοσ.

Re remali EPPITHS eisai???? Tha se karfoso ston Vardiampasi :-)))))

 

A re Tei Hrakleiou!!! Pantou eisai!!! Mexri kai sto Insomnia!!!

 

 

 

Ego to ebgala to prog me apla sindedemeni lista.

750+Grammes

Tou to estila shmera tou vardiampasi

 

Y.G: Sto poulao to prog! 10lepta i grami kodika :-)

 

Lol.....

 

 

Δημοσ.

Καλά το φαντάτικα ότι το πρόγραμμα ήταν του Βαρδιάμπαση. Αντε καλή επιτυχία. Αν δεν το ξέρετε ο βαρδιάμπασης είναι μέλος του φορουμ....

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...