Advertisement
fabioceep

Jogo3NumerosIguais

Apr 3rd, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. /*
  2.  
  3.     Regra do jogo:
  4.  Serão sorteados 3 numeros
  5.  se 2 iguais você ganha 25 de gold
  6.  se 3 iguais você ganha 100 de gold
  7.  
  8.  Objetivo: Ver a aplicação do IF ELSE
  9.  
  10.  
  11. */
  12.  
  13. #include <iostream>
  14. #include <ctime>
  15. #include <cstdlib>
  16.  
  17. using namespace std;
  18.  
  19. int main () {
  20.  
  21.     int n1,n2,n3;
  22.  
  23.       /*
  24.         srand inicializa o gerador de numeros aleatorios
  25.         deve ser utilizado apenas uma vez
  26.         unsigned = 0 até 4.294.967.295
  27.       */
  28.  
  29.       srand( (unsigned)time( NULL ) );
  30.  
  31.       // Gera numeros aleatorios grandes
  32.       n1 = rand() % 6 + 1 ;
  33.       n2 = rand() % 6 + 1 ;
  34.       n3 = rand() % 6 + 1;
  35.  
  36.       // Se 2 numeros iguais ganha 25 gold
  37.     cout << "| " << n1 << " | " << n2 << " | " << n3 << " | " << endl;
  38.     if ((n1 == n2) && (n2 == n3))
  39.     {
  40.         cout << "Parabens voce ganhou: Tres iguais" << endl;
  41.         cout << "+ 100 de gold" << endl;
  42.     } else
  43.      if((n1 == n2) || (n1 == n3))
  44.       {
  45.         cout << "Parabens voce ganhou: Dois iguais" << endl;
  46.         cout << "+ 25 de gold" << endl;
  47.       }
  48.        else
  49.         if (n2 == n3)
  50.         {
  51.             cout << "Parabens voce ganhou: Dois iguais" << endl;
  52.             cout << "+ 25 de gold" << endl;
  53.         }
  54.    return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement