Created
January 27, 2017 02:40
-
-
Save Adals20/3fd379cc8b910c5d3a7c0f456383f0e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdlib.h> //liberia que nos ayudara a crear los numeros aleatoreos | |
using namespace std; | |
int main() | |
{ | |
int x1, x2, v=0, c=0; | |
srand(time(NULL)); | |
x1 = rand()%100+1; | |
//cout << x1 << endl; // Linea para saber cual es el numero secreto y asi poder probar el programa | |
cout << "Trata de adivianar el numero que esta entre 1-100" << endl; | |
do { | |
cout << "Yo digo: "; | |
cin >> x2; | |
if (x2>x1) | |
cout << "Tu numero es más grande, intenta con otro más pequeño" << endl; | |
else | |
if (x2<x1) | |
cout << "Tu numero es más pequeño, intenta con otro más grande" << endl; | |
else | |
{ | |
cout << "Le has pegado al Gordo!" << endl; | |
cout << "Has intentado: " << c << " veces" << endl; | |
v = 1; | |
} | |
c += 1; | |
cout << " "<< endl; | |
} while(v==0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment