Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main()
- {
- srand( getpid() );
- int x, num, intentos;
- // Inicialización
- printf( "La patata caliente\n\n" );
- x = 0;
- intentos = 0;
- num = (rand() % 100) + 1; // 0 < num <= 100
- do {
- printf ( "Introduce un número entre 0 y 100\n" );
- scanf ( "%d" , x );
- intentos++;
- if ( num != x )
- printf ( "El numero es %s que %d\n", ( x>num ? "mayor" : "menor" ), x );
- } while ( num != x );
- printf ( "Has acertado con %d intentos\n.", intentos );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement