Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <time.h>
- #include <stdlib.h>
- #define MAX 6
- int rodaDados(int * d1, int * d2);
- void mostraValores(int d1, int d2);
- int main()
- {
- int d1, d2, ponto, soma;
- srand(time(NULL));
- rodaDados(&d1, &d2);
- mostraValores(d1, d2);
- soma = d1 + d2;
- if(soma == 7 || soma == 11)
- printf("O jogador venceu\n");
- else if(soma == 2 || soma == 3 || soma == 12)
- printf("A casa vence\n");
- else
- {
- ponto = soma;
- rodaDados(&d1, &d2);
- soma = d1 + d2;
- mostraValores(d1, d2);
- while(soma != ponto && soma != 7)
- {
- rodaDados(&d1, &d2);
- soma = d1 + d2;
- mostraValores(d1, d2);
- }
- if(soma == 7)
- printf("O jogador perdeu\n");
- else
- printf("O jogador ganhou\n");
- }
- getch();
- }
- int rodaDados(int * d1, int * d2)
- {
- *d1 = rand() % MAX + 1;
- *d2 = rand() % MAX + 1;
- }
- void mostraValores(int d1, int d2)
- {
- printf("Dado 1 = %d\n", d1);
- printf("Dado 2 = %d\n", d2);
- printf("Soma = %d\n", d1 + d2);
- }
Advertisement
Add Comment
Please, Sign In to add comment