Jogo 21 em C
Autor: Tiago Alves de Oliveira | Publicado: 2012-04-11T15:09:00-03:00

Buscando meus trabalhos de faculdade achei esse código de um jogo de 21 feito em C.
Para compilar use gcc -o jogo21 jogo21.c


/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
&nbsp;* main.c
&nbsp;* Copyright (C) Tiago Alves de Oliveira e Walisson Maicon Silva 2008 
&nbsp;*
&nbsp;* main.c is free software.
&nbsp;*
&nbsp;* You may redistribute it and/or modify it under the terms of the
&nbsp;* GNU General Public License, as published by the Free Software
&nbsp;* Foundation; either version 2 of the License, or (at your option)
&nbsp;* any later version.
&nbsp;*
&nbsp;* main.c is distributed in the hope that it will be useful,
&nbsp;* but WITHOUT ANY WARRANTY; without even the implied warranty of
&nbsp;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
&nbsp;* See the GNU General Public License for more details.
&nbsp;*
&nbsp;* You should have received a copy of the GNU General Public License
&nbsp;* along with main.c. &nbsp;If not, write to:
&nbsp;* &nbsp; &nbsp;The Free Software Foundation, Inc.,
&nbsp;* &nbsp; &nbsp;51 Franklin Street, Fifth Floor
&nbsp;* &nbsp; &nbsp;Boston, MA &nbsp;02110-1301, USA.
&nbsp;*/

#define LINUX &nbsp;1
// #define WINDOWS 1
//use define Linux se estiver usando o Linux e Windows para Windows

#ifdef LINUX
#include 
#include 
#include 
#include 
#endif
#ifdef WINDOWS
#include 
#include 
#include 
#include 
#endif

#define PUBLIC extern

#define ALOCA_NODO() &nbsp; &nbsp;( (Tmonte) malloc(sizeof(Tbaralho)) )
#define LIBERA_NODO(p) &nbsp;( free(p) )

typedef struct _carta_ //estrutura do baralho que vai ter o naipe o,c,e,p e valor da carta de 1 a 13
{
&nbsp; &nbsp;char naipe;
&nbsp; &nbsp;int valor;
} Tcarta;//carta

typedef struct _baralho_ //estrutura do baralho, que vai conter um tipo carta e o apontador para o proximo valor
{
&nbsp; &nbsp;Tcarta x;
&nbsp; &nbsp;struct _baralho_ *prox;
} Tbaralho; //baralho

typedef Tbaralho *Tmonte; //definindo o monte do tipo baralho

/*================*
&nbsp;* &nbsp;Inicia Fila
&nbsp;*================*/
PUBLIC Tmonte criaFila (void){
&nbsp; &nbsp;//aloca uma nova celula
&nbsp; &nbsp;Tmonte pcabeca = ALOCA_NODO();
&nbsp; &nbsp;//o valor desta celula recebe -1 para se diferenciar
&nbsp; &nbsp;pcabeca-&gt;x.valor = -1;
&nbsp; &nbsp;//ela aponta para ela mesma
&nbsp; &nbsp;pcabeca-&gt;prox &nbsp;= pcabeca;
&nbsp; &nbsp;//retornando esta celula para fazer ligação com a variavel que pediu ela
&nbsp; &nbsp;return pcabeca;
}

/*================*
&nbsp;* &nbsp;cria Baralho
&nbsp;*================*/

PUBLIC void criaBaralho(Tmonte *monte){
&nbsp; &nbsp;//montando o baralho &nbsp;
&nbsp; &nbsp;int i,j;
&nbsp; &nbsp;for(i=1;i<14 i="i" p="p">&nbsp; &nbsp;for(j=1;j<5 j="j" p="p">&nbsp; &nbsp; Tmonte novo = ALOCA_NODO();
&nbsp; &nbsp; novo-&gt;prox = (*monte)-&gt;prox;
&nbsp; &nbsp; (*monte)-&gt;prox = novo;
&nbsp; &nbsp; if (j == 1)
&nbsp; &nbsp; novo-&gt;x.naipe = 'o';
&nbsp; &nbsp; if (j == 2)
&nbsp; &nbsp; novo-&gt;x.naipe = 'c';
&nbsp; &nbsp; if (j == 3)
&nbsp; &nbsp; novo-&gt;x.naipe = 'e';
&nbsp; &nbsp; if (j == 4)
&nbsp; &nbsp; novo-&gt;x.naipe = 'p';
&nbsp; &nbsp; novo-&gt;x.valor = i;
&nbsp; &nbsp; (*monte)-&gt;prox=novo;
&nbsp; &nbsp;}
}
/*===================*
&nbsp;* Exibe o Baralho
&nbsp;*===================*/
PUBLIC void mostraBaralho(Tmonte *monte){
&nbsp; &nbsp;//exibe o baralho
&nbsp; &nbsp; Tbaralho *aux;
&nbsp; &nbsp;aux = (*monte)-&gt;prox;
&nbsp; &nbsp;while (aux-&gt;x.valor != -1){ &nbsp; //comparaçao de início da fila
&nbsp; &nbsp; &nbsp;printf("\nValor %d Naipe %c\n",aux-&gt;x.valor,aux-&gt;x.naipe);
&nbsp; &nbsp; &nbsp;aux = aux-&gt;prox;
&nbsp; &nbsp;}
&nbsp; &nbsp;
}

/*===========================*
&nbsp;* &nbsp; &nbsp;Pega uma carta
&nbsp;*===========================*/
PUBLIC Tcarta pegaCarta(Tmonte *monte)
{
&nbsp; &nbsp;Tbaralho *aux; Tcarta x;
&nbsp; &nbsp;aux = (*monte)-&gt;prox;
&nbsp; &nbsp;(*monte)-&gt;prox = aux-&gt;prox;
&nbsp; &nbsp;x = aux-&gt;x; 
&nbsp; &nbsp;LIBERA_NODO(aux);
&nbsp; &nbsp;return(x);
}

/*==========================*
&nbsp;* &nbsp; Devolve uma carta
&nbsp;*==========================*/

PUBLIC void devolveCarta(Tmonte *monte, Tcarta carta){
&nbsp; &nbsp;Tbaralho *aux = ALOCA_NODO();
&nbsp; &nbsp;aux-&gt;x = carta;
&nbsp; &nbsp;aux-&gt;prox &nbsp;= (*monte)-&gt;prox;
&nbsp; &nbsp;(*monte)-&gt;prox = aux;
}

/*=======================*
&nbsp;* &nbsp; Embaralha o Baralho
&nbsp;*=======================*/
PUBLIC void embaralha(Tmonte *monte){
&nbsp; &nbsp;//Embaralhar o Baralho
&nbsp; &nbsp;//para usar o random
&nbsp; &nbsp;srand(time(NULL));
&nbsp; &nbsp;Tbaralho *aux, *aux0;
&nbsp; &nbsp;Tmonte aux1 = criaFila(),aux2 = criaFila();
&nbsp; &nbsp;Tcarta x;
&nbsp; &nbsp;int p;
&nbsp; &nbsp;//aux está recebendo o monte-&gt;prox
&nbsp; &nbsp;aux = (*monte)-&gt;prox;
&nbsp; &nbsp;//enquanto aux-&gt;x.valor for diferente do flag
&nbsp; &nbsp;while (aux-&gt;x.valor != -1){
&nbsp; &nbsp; &nbsp; //pegando uma carta do endereço do ponteiro para monte
&nbsp; &nbsp; &nbsp; x = pegaCarta(&amp;(*monte));
&nbsp; &nbsp; &nbsp; //p vai receber um valor aleatório
&nbsp; &nbsp; &nbsp; p = rand() % 100;
&nbsp; &nbsp; &nbsp; //se o valor de p for par
&nbsp; &nbsp; &nbsp; if (p % 2 == 0)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//jogo ele na fila aux1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;devolveCarta(&amp;aux1,x);
&nbsp; &nbsp; &nbsp; //caso contrario jogo na fila aux2
&nbsp; &nbsp; &nbsp; else devolveCarta(&amp;aux2,x);
&nbsp; &nbsp; &nbsp; //aux vai receber monte-&gt;prox
&nbsp; &nbsp; &nbsp; aux = (*monte)-&gt;prox;
&nbsp; &nbsp;}
&nbsp; &nbsp;//monte que está vazio vai receber a fila aux1-&gt;prox
&nbsp; &nbsp;(*monte)-&gt;prox = aux1-&gt;prox;
&nbsp; &nbsp;aux = (*monte);
&nbsp; &nbsp;aux0 = (*monte)-&gt;prox;
&nbsp; &nbsp;while(aux0-&gt;x.valor != -1){
&nbsp; &nbsp; &nbsp; aux= aux-&gt;prox;
&nbsp; &nbsp; &nbsp; &nbsp;aux0= aux0-&gt;prox;
&nbsp; &nbsp;}
&nbsp; &nbsp;aux-&gt;prox= aux2-&gt;prox;
&nbsp; &nbsp;
}


/*========================*
&nbsp;* &nbsp; destroi Baralho &nbsp; 
&nbsp;*========================*/

PUBLIC void destroiBaralho (Tmonte *monte)
{
&nbsp; &nbsp;Tbaralho *aux;
&nbsp; &nbsp;Tcarta x;
&nbsp; &nbsp; //aux está recebendo o monte-&gt;prox
&nbsp; &nbsp;aux = (*monte)-&gt;prox;
&nbsp; &nbsp;//enquanto aux-&gt;x.valor for diferente do flag
&nbsp; &nbsp;while (aux-&gt;x.valor != -1){
&nbsp; &nbsp; &nbsp; //pegando uma carta do endereço do ponteiro para monte
&nbsp; &nbsp; &nbsp; x = pegaCarta(&amp;(*monte));
&nbsp; &nbsp; &nbsp; aux = (*monte)-&gt;prox;
&nbsp; &nbsp;}
}
/*===================*
&nbsp;* &nbsp; &nbsp; &nbsp; &nbsp;Jogar &nbsp; &nbsp; 
&nbsp;*===================*/
PUBLIC void jogar(Tmonte *monte,char nome1[], char nome2[], int *placar1, int *placar2){
&nbsp; &nbsp;srand(time(NULL));
&nbsp; &nbsp;int soma1=0, soma2=0;
&nbsp; &nbsp;Tcarta x1,x2;
&nbsp; &nbsp;char ch;
&nbsp; &nbsp;int op2;
&nbsp; &nbsp; do{
&nbsp; &nbsp; &nbsp; x1.valor=x2.valor=0;
&nbsp; &nbsp; &nbsp; x1.naipe=x2.naipe='a';
&nbsp; &nbsp; &nbsp; system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; printf("\n******** Menu do Jogo ************\n\n");
&nbsp; &nbsp; &nbsp; &nbsp; printf("\n1- Pegar Carta\n");
&nbsp; &nbsp; &nbsp; &nbsp; printf("\n2- Não Pegar uma Carta\n");
&nbsp; &nbsp; &nbsp; &nbsp; printf("\n3- Sair \n");
&nbsp; &nbsp; &nbsp; &nbsp; printf("\nEntre com a sua Opção: \n");
&nbsp; &nbsp; &nbsp; &nbsp; scanf("%d", &amp;op2);
&nbsp; &nbsp; &nbsp; switch (op2){
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 1:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x1 = pegaCarta(&amp;(*monte));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("Você pegou a carta %d %c\n", x1.valor, x1.naipe);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (soma2==0){
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = pegaCarta(&amp;(*monte));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("Computador pegou a carta %d %c\n", x2.valor, x2.naipe);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soma2 += x2.valor;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int r=rand()%2;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (r==1){
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = pegaCarta(&amp;(*monte));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soma2 += x2.valor;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("Computador pegou a carta %d %c\n", x2.valor, x2.naipe);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else printf("Computador não pegou uma carta\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;soma1 += x1.valor; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; case 2:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("Você não pegou uma carta \n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (soma2==0){
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = pegaCarta(&amp;(*monte));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("Computador pegou a carta %d %c\n", x2.valor, x2.naipe);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soma2 += x2.valor;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int r=rand()%2;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (r==1){
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = pegaCarta(&amp;(*monte));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soma2 += x2.valor;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("Computador pegou a carta %d %c\n", x2.valor, x2.naipe);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else printf("Computador não pegou uma carta\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;soma1 += x1.valor; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; case 3:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("\nSaindo do Jogo\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; default:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("\nEntre com um valor válido!\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;printf("Soma do Jogador 1 (Você)%d\n", soma1);
&nbsp; &nbsp; &nbsp;printf("Soma do Jogador 2 (Computador)%d\n", soma2);
&nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp;}while ((soma1 &lt; 21) &amp;&amp; (soma2 &lt; 21) &amp;&amp; (op2!=3));
&nbsp; &nbsp;if ((soma1&gt;21) &amp;&amp; (soma2&gt;21))
&nbsp; &nbsp; &nbsp; printf("O jogo ficou empatado\n");
&nbsp; &nbsp;else if (soma1 &gt; 21){
&nbsp; &nbsp; &nbsp; printf("Você perdeu esta rodada\n");
&nbsp; &nbsp; &nbsp; (*placar2)++;
&nbsp; &nbsp;}
&nbsp; &nbsp;else if(soma2 &gt; 21){
&nbsp; &nbsp; &nbsp; printf("Você ganhou esta rodada\n");
&nbsp; &nbsp; &nbsp; (*placar1)++;
&nbsp; &nbsp;}
&nbsp; &nbsp;else if(soma1 == 21){
&nbsp; &nbsp; &nbsp; printf("Você ganhou esta rodada\n");
&nbsp; &nbsp; &nbsp; (*placar1)++;
&nbsp; &nbsp;}
&nbsp; &nbsp;else if(soma2 == 21){
&nbsp; &nbsp; &nbsp; printf("Você perdeu esta rodada\n");
&nbsp; &nbsp; &nbsp; (*placar2)++;
&nbsp; &nbsp;}
&nbsp; &nbsp;else if ((soma1==21) &amp;&amp; (soma2==21))
&nbsp; &nbsp; &nbsp; printf("O jogo ficou empatado\n");
&nbsp; &nbsp;else if (soma1&gt;soma2){
&nbsp; &nbsp; &nbsp; printf("Você ganhou esta rodada\n");
&nbsp; &nbsp; &nbsp; (*placar1)++;
&nbsp; &nbsp;}
&nbsp; &nbsp;else if (soma1&nbsp; &nbsp; &nbsp; printf("Você perdeu esta rodada\n");
&nbsp; &nbsp; &nbsp; (*placar2)++;
&nbsp; &nbsp;}
&nbsp; &nbsp;else printf("O jogo ficou empatado\n");
&nbsp; &nbsp;destroiBaralho(&amp;(*monte));
}

int main(void){
&nbsp; &nbsp;char ch;
&nbsp; &nbsp;int op;
&nbsp; &nbsp;char nome1[10],nome2[20];
&nbsp; &nbsp;system("clear");
&nbsp; &nbsp;printf("Jogador 1 entre com o seu nome : ");
&nbsp; &nbsp;fflush(stdin);
&nbsp; &nbsp;fgets(nome1,10,stdin);
&nbsp; &nbsp;printf("Bem Vindo %s", nome1);
&nbsp; &nbsp;strcpy(nome2,"Computador"); &nbsp;
&nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp;system("clear");
&nbsp; &nbsp;/*Criando a Fila*/
&nbsp; &nbsp;Tmonte monte = criaFila();
&nbsp; &nbsp;/*Criando o Baralho */
&nbsp; &nbsp;criaBaralho(&amp;monte);
&nbsp; &nbsp;int i;
&nbsp; &nbsp;/*Embaralhando o Baralho*/
&nbsp; &nbsp;for (i=0;i<10 i="i" p="p">&nbsp; &nbsp;embaralha(&amp;monte);
&nbsp; &nbsp;int placar1 = 0, placar2= 0;
&nbsp; &nbsp;do{
&nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp;printf("\n*************** Menu ***************\n\n");
&nbsp; &nbsp; &nbsp;printf("\n1- Mostrar o Baralho\n");
&nbsp; &nbsp; &nbsp;printf("\n2- Jogar\n");
&nbsp; &nbsp; &nbsp;printf("\n3- Ver Placar\n");
&nbsp; &nbsp; &nbsp;printf("\n4- Zerar Placar\n");
&nbsp; &nbsp; &nbsp;printf("\n5- Sair \n");
&nbsp; &nbsp; &nbsp;printf("\nEntre com a sua Opção: \n");
&nbsp; &nbsp; &nbsp;scanf("%d", &amp;op);
&nbsp; &nbsp; &nbsp;switch(op){
&nbsp; &nbsp; &nbsp; &nbsp; case 1:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("Mostrando o Baralho\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mostraBaralho(&amp;monte);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; case 2:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jogar(&amp;monte, nome1, nome2, &amp;placar1, &amp;placar2);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*Criando o Baralho */
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;criaBaralho(&amp;monte);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int i;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*Embaralhando o Baralho*/
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (i=0;i<10 i="i" p="p">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; embaralha(&amp;monte);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; case 3:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("Placar de %s : %d \n", nome1, placar1);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("Placar do %s : %d \n", nome2, placar2);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; case 4:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;placar1 = placar2 = 0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("Placar Zerado\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; case 5:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;system("clear");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("\nSaindo do Programa\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit (0);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; default:{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("\nEntre com um valor válido!\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;scanf("%c", &amp;ch);
&nbsp; &nbsp;}while (op != 5);
&nbsp; &nbsp;
&nbsp; &nbsp;return 0;
}