ok I think i figured it ould actually got something acomplished but i may need one thing done.....
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i,j,k;
bool cards[52];
char *suits[]={"Heart ",
"Club ",
"Diamond ",
"Spade "};
char *faces[]={"Ace ","1 ","2 ","3 ","4 ","5 ","6 ",
"7 ","8 ","9 ","10 ","Jack ","Queen","King "};
// Initializing the array
// aka, putting all of the cards in the deck
for(i = 0; i < 52; i++) {
cards[i] = 1;
}
// Seeding the random number generator
srand(time(NULL));
printf("Before Sorting\n\n"
" Suit Value\n"
" ----- -----\n");
for(i = 0; i < 5; i++) {
do {
j = rand()%52;
} while(cards[j]==0);
// Removing the card from the deck
cards[j] = 0;
printf(" %s %s\n",suits[j/13],faces[j%13]);
}
// sort the cards
printf("\nAfter Sorting\n\n"
" Suit Value\n"
" ----- -----\n");
for(i=0;i<13;++i) {
for(j=0;j<4;++j) {
k=i+j*13;
if(cards[k]) {
printf(" %s %s\n",suits[k/13],faces[k%13]);
}
}
}
system("pause");
return 0;
}
I just want it to sort the cards it already picked. The way it works, is that I think it prints out 47 cards and not the ones that were already picked. Do you know how I can fix this? Maybe there is just a little trick I need to do in the code to make it work?