Está en la página 1de 2

ADIVINA EL NUMERO

trata de asestarle a un numero que se crea al azar dependiendo de la dificultad

Te ira avisando si te pasaste o si aun falta


#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
main()
{     START:
      srand(time(NULL));
      system("color f1");
      system("cls");
      int n_winner, n, n_wmax, intentos, inte=0, lvl, frandom, i;      
      printf("tJuego "Acierta al numero"nn");
      printf("Ingresa el numero del nivel de dificultad: nn1.-Facil(0-
10)  tt 4 Intentosn2.-Normal(0-100)  tt 7 Intentosn3.-Dificil(0-1000)  
tt13 Intentosn4.-Muy dificil(0-10000)  t17 Intentosn=");
      scanf("%i", &lvl);
      if(lvl==1)
      {
      n_wmax=10;
      intentos=4;
      }
      else if(lvl==2) 
      {
      n_wmax=100;
      intentos=7;
      }
      else if(lvl==3)
      {
      n_wmax=1000;
      intentos=13;
      }
      else if(lvl==4)
      {
      n_wmax=10000;
      intentos=17;
      }
      else 
      {
           printf("La opcion elegida no existe"); 
           system("pause");
      goto START;      
      }
      system("color f1");
      for(i=0;i<=rand();i+=4)frandom=rand()%n_wmax;    
      n_winner = frandom;
      system("cls");
      RETRY:
      printf("tJuego "Acierta al numero"nn");
      printf("Intenta acertar cual es el numero: ");
      scanf("%i", &n);
      inte++;
      printf("Te quedan %i intento(s)nn", intentos-inte);
      if(n==n_winner)
      {    
           system("color f2");
           printf("Felicidades, Has ganado!!n");
           system("pause");
           goto START;
      }
      else if (n<n_winner)
      {
           printf("Tu numero es demaciado bajo!!nnPreciona una tecla..
.");
           system("pause>NULL");
      }      
      else
      {
           printf("Te pasaste!!nnPreciona una tecla...");
           system("pause>NULL");
      }
      system("cls");
      if (inte>=intentos)
      {
      printf("Lo siento se te acabaron los intentos, el numero era "%i
"nnt", n_winner);
      system("pause");
      goto START;
      }
goto RETRY;
}

También podría gustarte