Advertisement
lButcherl

Lógica - 02

Oct 7th, 2013
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. main(){
  4.        int num1,num2,tot;
  5.        char play1;
  6.        printf("Jogador 1: I para Impar ou P para Par: ");
  7.        scanf("%c",&play1);
  8.        printf("Informe o numero do primeiro jogador: ");
  9.        scanf("%i",&num1);
  10.        printf("Informe o numero do segundo jogador: ");
  11.        scanf("%i",&num2);
  12.        tot = num1+num2;
  13.        if (play1 != 'p' && play1 != 'i' && play1 != 'I' && play1 != 'P'){
  14.                  printf("Fatal error!\n");
  15.                  }
  16.        if (tot%2 == 0){
  17.                  if (play1 == 'p' || play1 == 'P'){
  18.                            printf("Jogador 1 venceu! O total deu %i\n",tot);
  19.                            }
  20.                            if (play1 == 'i' || play1 == 'I'){
  21.                                      printf("Jogador 2 venceu! O total deu %i\n",tot);
  22.                                      }
  23.                            }
  24.                            else {
  25.                                 if (play1 == 'p' || play1 == 'P'){
  26.                                           printf("Jogador 2 venceu! O total deu %i\n",tot);
  27.                                           }
  28.                                           if (play1 == 'i' || play1 == 'I'){
  29.                                                     printf("Jogador 1 venceu! O total deu %i\n",tot);
  30.                                                     }
  31.                                                     }
  32.        system("pause");
  33.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement