Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program: adivinar.cc
- // Author: Yoan Pinzon
- // Date: Agosto 30, 2006
- #include <iostream>
- #include <string>
- using namespace std;
- int main(){
- const string numletras[]={"primer", "segundo", "tercer", "cuarto", "quinto",
- "sexto", "septimo", "octavo", "noveno", "decimo"};
- const int n=81;
- int x, c=0;
- cout << "Adivinando un numero n entre 1 y 100" << endl;
- cout << "====================================" << endl;
- do{
- cout << "Entre x: "; cin >> x; c++;
- if( x == -1 ){
- cout << "Muy malo! usted aborto el programa despues del ";
- if(c<=10) cout << numletras[c-2] << " intento" << endl;
- else cout << c-1 << " intento" << endl;
- return 0;
- }
- if( x > n ) cout << x << ">n" << endl;
- else if( x < n ) cout << x << "<n" << endl;
- } while(x != n);
- cout << x << "=n felicitaciones!, usted adivino el numero en el ";
- if(c<=10) cout << numletras[--c] << " intento" << endl;
- else cout << c << " intento" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement