Created
February 14, 2015 06:48
-
-
Save samir96/2dd4e14bfc5912035341 to your computer and use it in GitHub Desktop.
Pick a number
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 <cstdlib> | |
#include <ctime> | |
using namespace std; | |
int main(){ | |
int numerores, numerointento, intento=0; | |
srand(time(NULL)); | |
numerores=rand()%100+1; | |
while(numerores!=numerointento){ | |
intento=intento+1; | |
cout<<"\nAdivina el numero que estoy pensando entre 1 y 100: "; | |
cin>>numerointento; | |
if(numerointento>numerores){ | |
cout<< "\nEste numero es mayor que mi numero "<<endl; | |
} | |
if(numerointento<numerores){ | |
cout<< "\nEste numero es menor que mi numero "<<endl; | |
} | |
if(numerointento==numerores){ | |
cout<< "\nFelicidades has acertado! "<<endl; | |
cout<< "\nEl numero de intentos que has realizado para adivinar el numero es de: "<<intento<< " "<<endl; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment