#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
char f_carta[13][4];
int rnd(int range);
void seedrnd(void);
void main(){
char carta[2],flag=' ',resp=' ';
int x,i,j,tot=0;
printf("********** X e Um V1.0 (Beta)**********\n\n\n\n");
printf("Digite o valor de X: ");
scanf("%d",&x);
fflush(stdin);
printf("\nPressione alguma tecla para iniciar.");
getchar();
fflush(stdin);
do{
do{
seedrnd();
i=rnd(13)+1;
j=rnd(4)+3;
if (f_carta[i][j]!='*'){
f_carta[i][j]='*';
flag='*';
}
}while (flag!='*');
flag=' ';
switch(i){
case 1:
strcpy(carta,"A");
break;
case 2:
strcpy(carta,"2");
break;
case 3:
strcpy(carta,"3");
break;
case 4:
strcpy(carta,"4");
break;
case 5:
strcpy(carta,"5");
break;
case 6:
strcpy(carta,"6");
break;
case 7:
strcpy(carta,"7");
break;
case 8:
strcpy(carta,"8");
break;
case 9:
strcpy(carta,"9");
break;
case 10:
strcpy(carta,"10");
break;
case 11:
strcpy(carta,"J");
break;
case 12:
strcpy(carta,"Q");
break;
case 13:
strcpy(carta,"K");
break;
}
printf("\nA carta tirada foi %s de %c !\n",carta,j);
if (i>9)
tot+=10;
else
tot+=i;
printf("Total de pontos = %d\n\n",tot);
if (tot==x)
printf("\n%c Ganhou!!!\n",2);
else
if (tot>x){
printf("\n%c Perdeu...\n",1);
printf("\n\nTotal de pontos = %d",tot);
fflush(stdin);
getchar();
exit(0);
}
else{
printf("Continuar? ");
fflush(stdin);
resp=getchar();
}
}while (resp!='n' && resp!='N');
printf("\n\nTotal de pontos = %d",tot);
fflush(stdin);
getchar();
}
int rnd(int range)
{
int r;
r=rand()%range;
return(r);
}
void seedrnd(void)
{
srand((unsigned)time(NULL));
}