Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <windows.h>
- #define limpiar system("cls");
- #define pausa system("pause >> void");
- using namespace std;
- int main(){
- int opcion, numeroAleatorio, numeroUsuario, vidas;
- float probabilidad;
- menu:
- system("title Adivina el numero");
- system("color 0f");
- limpiar;
- vidas=5;
- cout << "Adivina el numero" << endl << endl;
- cout << "1. Facil -> (del 1 al 15)" << endl;
- cout << "2. Normal -> (del 1 al 25)" << endl;
- cout << "3. Dificil -> (del 1 al 50)" << endl;
- cout << "Elige la dificultad (escribe el numero): "; cin >> opcion;
- switch(opcion) {
- case 1:
- limpiar;
- system("title Dificultad facil. 1-15");
- system("color 0A");
- numeroAleatorio = rand() % 15 + 1;
- while (vidas > 0)
- {
- limpiar;
- cout << "Escribe un numero: "; cin >> numeroUsuario;
- if (numeroUsuario == numeroAleatorio)
- {
- limpiar;
- system("title Has ganado.");
- cout << "Bien! Has adivinado el numero en la dificultad facil." << endl;
- cout << "Probabilidades de ganar: 33.3%";
- pausa;
- goto menu;
- }
- if (numeroUsuario > numeroAleatorio)
- {
- limpiar;
- cout << "El numero aleatorio es MENOR que tu numero." << endl;
- vidas--;
- cout << "Vidas restantes: " << vidas << endl << endl;
- cout << "Volviendo..." << endl;
- Sleep(2000);
- }
- if (numeroUsuario < numeroAleatorio)
- {
- limpiar;
- cout << "El numero aleatorio es MAYOR que tu numero." << endl;
- vidas--;
- cout << "Vidas restantes: " << vidas << endl << endl;
- cout << "Volviendo..." << endl;
- Sleep(2000);
- }
- }
- limpiar;
- cout << "Has perdido en la dificultad facil!" << endl;
- cout << "Probabilidades de ganar: 33.3%" << endl << endl;
- cout << "El numero aleatorio era " << numeroAleatorio;
- pausa;
- goto menu;
- case 2:
- limpiar;
- system("title Dificultad normal. 1-25");
- system("color 0B");
- numeroAleatorio = rand() % 25 + 1;
- while (vidas > 0)
- {
- limpiar;
- cout << "Escribe un numero: "; cin >> numeroUsuario;
- if (numeroUsuario == numeroAleatorio)
- {
- limpiar;
- system("title Has ganado.");
- cout << "Muy bien! Has adivinado el numero en la dificultad normal." << endl;
- cout << "Probabilidades de ganar: 20%";
- pausa;
- goto menu;
- }
- if (numeroUsuario > numeroAleatorio)
- {
- limpiar;
- cout << "El numero aleatorio es MENOR que tu numero." << endl;
- vidas--;
- cout << "Vidas restantes: " << vidas << endl << endl;
- cout << "Volviendo..." << endl;
- Sleep(2000);
- }
- if (numeroUsuario < numeroAleatorio)
- {
- limpiar;
- cout << "El numero aleatorio es MAYOR que tu numero." << endl;
- vidas--;
- cout << "Vidas restantes: " << vidas << endl << endl;
- cout << "Volviendo..." << endl;
- Sleep(2000);
- }
- }
- limpiar;
- cout << "Has perdido!" << endl;
- cout << "Probabilidades de ganar: 20%" << endl << endl;
- cout << "El numero aleatorio era " << numeroAleatorio;
- pausa;
- goto menu;
- case 3:
- limpiar;
- system("title Dificultad difícil. 1-50");
- system("color 0E");
- numeroAleatorio = rand() % 50 + 1;
- while (vidas > 0)
- {
- limpiar;
- cout << "Escribe un numero: "; cin >> numeroUsuario;
- if (numeroUsuario == numeroAleatorio)
- {
- limpiar;
- system("title Has ganado.");
- cout << "Felicidades! Has adivinado el numero en la dificultad difícil." << endl;
- cout << "Probabilidades de ganar: 10%";
- pausa;
- goto menu;
- }
- if (numeroUsuario > numeroAleatorio)
- {
- limpiar;
- cout << "El numero aleatorio es MENOR que tu numero." << endl;
- vidas--;
- cout << "Vidas restantes: " << vidas << endl << endl;
- cout << "Volviendo..." << endl;
- Sleep(2000);
- }
- if (numeroUsuario < numeroAleatorio)
- {
- limpiar;
- cout << "El numero aleatorio es MAYOR que tu numero." << endl;
- vidas--;
- cout << "Vidas restantes: " << vidas << endl << endl;
- cout << "Volviendo..." << endl;
- Sleep(2000);
- }
- }
- limpiar;
- cout << "Has perdido :(" << endl;
- cout << "Probabilidades de ganar: 10%" << endl << endl;
- cout << "El numero aleatorio era " << numeroAleatorio;
- pausa;
- goto menu;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement