Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main () {
- int i, dificuldade, numero, tentativa, flag, flagb;
- srand(time(0));
- flag = 0;
- flagb = 0;
- do{
- do{
- cout << "Select A Dificulty (1 = Easy / 2 = Medium / 3 = Hard): ";
- cin >> dificuldade;
- }while (dificuldade != 1 && dificuldade != 2 && dificuldade != 3 && dificuldade != 69);
- //------------------ 1 ---------------------//
- if(dificuldade == 1){
- numero = rand() % 100 + 1;
- if(numero < 1)
- numero = numero * -1;
- for(i=0;i<9;i++){
- cout << endl << "Insert A Number: ";
- cin >> tentativa;
- if (numero == tentativa){
- flag = 1;
- cout << endl << "You Won." << endl;
- break;
- }
- else{
- if (numero > tentativa)
- cout << endl << "Low. You Have " << 8-i << " Tries." << endl;
- if (numero < tentativa)
- cout << endl << "High. You Have " << 8-i << " Tries." << endl;
- }
- }
- }
- //------------------ 2 --------------------//
- if(dificuldade == 2){
- numero = rand() % 100 + 1;
- if(numero < 1)
- numero = numero * -1;
- for(i=0;i<7;i++){
- cout << endl << "Insert A Number: ";
- cin >> tentativa;
- if (numero == tentativa){
- flag = 1;
- cout << endl << "You Won." << endl;
- break;
- }
- else{
- if (numero > tentativa)
- cout << endl << "Low. You Have " << 6-i << " Tries." << endl;
- if (numero < tentativa)
- cout << endl << "High. You Have " << 6-i << " Tries." << endl;
- }
- }
- }
- //------------------- 3 -------------------//
- if(dificuldade == 3){
- numero = rand() % 200 + 1;
- if(numero < 1)
- numero = numero * -1;
- for(i=0;i<7;i++){
- cout << endl << "Insert A Number: ";
- cin >> tentativa;
- if (numero == tentativa){
- flag = 1;
- cout << endl << "You Won." << endl;
- break;
- }
- else{
- if (numero > tentativa)
- cout << endl << "Low. You Have " << 6-i << " Tries." << endl;
- if (numero < tentativa)
- cout << endl << "High. You Have " << 6-i << " Tries." << endl;
- }
- }
- }
- if (dificuldade == 69){
- cout << endl << "Really?" << endl;
- flag = 1;
- }
- if (flag == 0)
- cout << endl << "You Lost. The Number was: " << numero << endl;
- cout << endl << "Want To Play Again? (0 = No / 1 = Yes): ";
- cin >> flagb;
- if (flagb == 1)
- cout << endl;
- }while(flagb == 1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement