I am trying to make this program where the user input the number of cards they wanna draw and the computer displays the suit and the card. I have used random number, a switch statement for the special case of Ace, Queen, King and Jack, and a for() loop for the number of cards desired. i have also used a check that the input is not anything other than 0-52. the problem that I have is the repetition of cards, and i want to know if there is a way to draw from only the leftover cards. please help ASAP. Thank you!
Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int cardcheck(int x);
card(int y, int z);
main(){
int a,b,c,d,e,f,g,h[52],i;
printf("Say how many cards do you wanna draw? ");
scanf("%d",&c);
cardcheck(c);
srand(time(NULL));
for(d=0;d<c;d++){
a= 3+(rand()%4);
b= 1+(rand()%13);
card(a,b);
}
}
cardcheck(int x){
if(x>=0 && x<=52)
printf(" \b");
else{
printf("Invalid input");
exit(0);
}
}
card(int y,int z){
switch (z){
case(1):
printf("The card you drew is a A of %c\n",y);
break;
case(11):
printf("The card you drew is a Jack of %c\n",y);
break;
case(12):
printf("The card you drew is a Queen of %c\n",y);
break;
case(13):
printf("The card you drew is a King of %c\n",y);
break;
default:
printf("The card you drew is a %d of %c\n",z,y);
break;
}
}