Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Regra do jogo:
- Serão sorteados 3 letras
- se 2 iguais você ganha 25 de gold
- se 3 iguais você ganha 100 de gold
- Objetivo: Ver a aplicação do IF ELSE
- */
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main () {
- int n1,n2,n3;
- char c1, c2, c3;
- /*
- srand inicializa o gerador de numeros aleatorios
- deve ser utilizado apenas uma vez
- unsigned = 0 até 4.294.967.295
- */
- srand( (unsigned)time( NULL ) );
- // Gera numeros aleatorios grandes
- n1 = rand() % 6 + 1;
- n2 = rand() % 6 + 1;
- n3 = rand() % 6 + 1;
- c1 = 65+n1;
- c2 = 65+n2;
- c3 = 65+n3;
- // Se 2 numeros iguais ganha 25 gold
- cout << "| " << c1 << " | " << c2 << " | " << c3 << " | " << endl;
- if ((n1 == n2) && (n2 == n3))
- {
- cout << "Parabens voce ganhou: Tres iguais" << endl;
- cout << "+ 100 de gold" << endl;
- } else
- if((n1 == n2) || (n1 == n3))
- {
- cout << "Parabens voce ganhou: Dois iguais" << endl;
- cout << "+ 25 de gold" << endl;
- }
- else
- if (n2 == n3)
- {
- cout << "Parabens voce ganhou: Dois iguais" << endl;
- cout << "+ 25 de gold" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement