1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
void shuffle(int wDeck[] [13]);
void deal(const int wDeck[][13], const char *wFace[],
const char *wSuit[], const char *wplayer1[][5], const char *wplayer2[]);
int main(void)
{
const char *suit[4] = {"Hearts", "Diamonds", "Clubs", "Spades"};
const char *face[13]= {"Ace", "Deuce", "Three", " Four", "Five", "Six", "Seven",
"Eight", "Nine", "Ten", "Jack", "Queen", "King"};
const char *player1[5][5];
const char *player2[5];
int deck[4][13] = {0};
srand(time(0));
shuffle(deck);
deal(deck, face, suit, player1, player2);
printf("\n");
return 0;
}
void deal(const int wDeck[][13], const char *wFace[],
const char *wSuit[], const char *wplayer1[][5], const char *wplayer2[] )
{
int card;
int row;
int column;
int s;
for(card =1; card <= 10; card++){
if(card<=5){
for(row = 0; row <= 3; row++){
for(column = 0; column <= 12; column++){
if(wDeck[row][column] ==card){//<<==problem
wplayer1[card]= wFace[column], wSuit[row];
cout<<wFace[column]<<" of "<<wSuit[row]<<"\n";
}
}
}
}
else if(card<=10){
for(row = 0; row <= 3; row++){
for(column = 0; column <= 12; column++){
{if(wDeck[row][column] ==card){
wplayer1[card]= wFace[column], wSuit[row];
cout<<wFace[column]<<" of "<<wSuit[row]<<"\n";
}
}
}
}
}
}
for(int i=1; i<=5; i++){
cout<<"player 1 cards "<<wplayer1[i]<<endl;
}
}
|