Created
April 11, 2017 20:59
-
-
Save peterbrendel/6133f672dd4e166bab8a0d42b616c7f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
void preparar(int baralho[][13]); | |
void distribuir(int baralho[][13], const char *naipes[], | |
const char *valores[]); | |
int main(void){ | |
int baralho[4][13] = {0}; | |
const char *naipes[4] = {"ouro", "espada", | |
"paus", "copas"}; | |
const char *valores[13] = {"As", "Dois", "Tres", | |
"Quatro", "Cinco","Seis", | |
"Sete","Oito","Nove","Dez", | |
"Valete","Dama","Rei"}; | |
srand(time(NULL)); | |
preparar(baralho); | |
distribuir(baralho, naipes, valores); | |
return 0; | |
} | |
void preparar(int baralho[][13]){ | |
int i, l, c; | |
for(i=1; i<=52; i++){ | |
do{ | |
l = rand()%4; | |
c = rand()%13; | |
}while(baralho[l][c] != 0); | |
baralho[l][c] = i; | |
} | |
} | |
void distribuir(int baralho[][13], | |
const char *naipes[], | |
const char *valores[]){ | |
int i, l, c; | |
for(i=1; i<=52; i++){ | |
for(l=0; l<4; l++){ | |
for(c=0; c<13; c++){ | |
if(i == baralho[l][c]){ | |
printf("%s\tde\t%s\n", valores[c], | |
naipes[l]); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment