Skip to content

Instantly share code, notes, and snippets.

@Adals20
Created January 27, 2017 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adals20/3fd379cc8b910c5d3a7c0f456383f0e5 to your computer and use it in GitHub Desktop.
Save Adals20/3fd379cc8b910c5d3a7c0f456383f0e5 to your computer and use it in GitHub Desktop.
#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