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 81
|
#include <stdio.h>
#include "HelperFunctions.h"
#define FIVE 5
void main()
{
int deck[4][13];
for(int row = 0; row < 4; ++row)
{
for(int col = 0; col < 13; ++col)
{
deck[row][col] = 1;
}
}
int totalCards = 0;
int cardDeleter = 0;
int i = 0;
do
{
totalCards = 0;
printf("**********Deck Of Cards*********\n");
printf("* A 2 3 4 5 6 7 8 9 T J Q K *\n*\t\t\t *\n");
for(int row = 0; row < 4; ++row)
{
if(row == 0){printf("*%c ", char(3));}
if(row == 1){printf("*%c ", char(4));}
if(row == 2){printf("*%c ", char(5));}
if(row == 3){printf("*%c ", char(6));}
for(int col = 0; col < 13; ++col)
{
printf("%d ", deck[row][col]);
if(deck[row][col] == 1)
{
totalCards++;
}
}
printf("*\n");
}
printf("********************************\n");
if(cardDeleter < 13)
{
if( i == 0 ){deck[i][cardDeleter] = 0;}
if( i == 1 ){deck[i][cardDeleter] = 0;}
if( i == 2 ){deck[i][cardDeleter] = 0;}
if( i == 3 ){deck[i][cardDeleter] = 0;}
int tempCard = cardDeleter;
if (tempCard == 0){printf("Deleted Card %c of %c \n", (char)65, (char)i + 3);}
else if(tempCard == 9){printf("Deleted Card %c of %c \n", (char)84, (char)i + 3);}
else if(tempCard == 10){printf("Deleted Card %c of %c \n", (char)74, (char)i + 3);}
else if(tempCard == 11){printf("Deleted Card %c of %c \n", (char)81, (char)i + 3);}
else if(tempCard == 12){printf("Deleted Card %c of %c \n", (char)75, (char)i + 3);}
else {printf("Deleted Card %d of %c \n", tempCard, (char)i + 3);}
}
if(cardDeleter >= 13)
{
cardDeleter -= 13;
i++;
}
else
{
cardDeleter += FIVE;
}
if(i == 4){i = 0;}
Wait(1, 50);
if(totalCards != 0)
{
ResetCursorPosition(0, 0);
}
} while(totalCards != 0);
}
|