/* genera el vector super incremental */
void generaVectorSI (void) {
  unsigned int i, j, sumVectorSI;

  printf("generando vector super incremental:\n");

  /* inicamos con un byte aletorio */
  vectorSI[0] = aleatorio();
  printf("%i, %u (%u)\n", 0, vectorSI[0], 0);

  /* demas bytes */
  for (i = 1; i < 8; i++) {
    sumVectorSI = 0;
    /* calculamos suma de los escalares previos */
    for (j = 0; j < i; j++) {
      sumVectorSI += vectorSI[j];
    }
    /* calculamos nuevo escalar */
    vectorSI[i] = vectorSI[i - 1] + aleatorio();
    while (vectorSI[i] < sumVectorSI) {
      vectorSI[i] = vectorSI[i] + aleatorio();
    }
    printf("%i, %u (%u)\n", i, vectorSI[i], sumVectorSI);
  }
printf("\n");
}
int main()
{
	int m,n,q,x,y,i;
	Par *inicio = NULL,*fim;
	Arv *inicioArv = NULL;
	bool simetria;
	printf("Informe numero minimo:");
	scanf("%d",&m);
	if(m >= 0){ //verifica se o numero minimo é positivo
		printf("Informe o numero maximo:");
		scanf("%d",&n);
		if(n <= 100){
			n++;
			if(n-m > 0){ //verifica se o intervalo contém algum elemento
				printf("Informe o numero de elementos a serem gerados: ");
				scanf("%d",&q);
				if(((n-m)*(n-m)) >= q){ //verifica se o numero de pares a serem gerados é menor ou igual aos pares disponiveis no intervalo
					srand(time(NULL)); //inicializar a função rand -> seed rand
					for(i=0;i<q;i++){ //repete as instruções abaixo por q vezes, definido pelo usuário
						x = aleatorio(m,n); //criar um numero aleatório, entre m e n, definidos pelo usuário.
						y = aleatorio(m,n);
						if(!(repetido(inicio,x,y))){ //inserir os elementos enquanto não há pares repetidos
							inserir(&inicio,&fim,x,y); //insere o par em uma estrutura dinâmica
						}else{
							i--; //retroceder no loop for e gerar novo par, caso haja um par repetido
						}
					}
					imprimir(inicio); //imprime todos os pares ordenados
					simetria = Simetrico(inicio);
					printf("\n%d\n",simetria);// Nao Simetrico.Vai imprimir a ordem simetrica das coordenadas.
						if(!(simetria)){// se Simetria nao for verdadeiro ou seja se retornar valor 0 ele entra na condicao.
							getch();
							transferir(inicio,&inicioArv);// vai transferir os itens da lista para a estrutura arvore e ordenar.
							imprimirArv(inicioArv);
						}
					
				}else{
					printf("Nao existem pares suficientes no intervalo escolhido.\n");
				}
			}else{
				printf("Intervalo Invalido.\n");
			}
		}else{
			printf("Limite superior maximo: 100\n");
		}
	}else{
		printf("Numero Invalido.\n");
	}
	return 0;
}
tabuleiro *resolver(tabuleiro *tab){
	char tmp[100][100];
	int lin,col;
	tabuleiro *f, *w, *z, *x;

		do{
			for(lin=0;lin!=tab->tamanho[0];lin++)
				for(col=0;col!=tab->tamanho[1];col++)
					tmp[lin][col]=tab->quadro[lin][col];
	   
        	f=aloca(tab);
        	w=verigual(tab,estra1(f));

        	f=aloca(w);
        	z=verigual(w,estra2(f));
	
        	f=aloca(z);
        	x=verigual(z,estra3(f));

        	f=aloca(x);
        	tab=verigual(x,estra4(f));


		}while(changes(tmp,tab) && verifica(tab)!=2);

		if(verifica(tab)==2);
		else tab=aleatorio(tab,0);


	return tab;
}
Exemple #4
0
void testVectorDesordenadoAleatorio() {
	int n = 32001, i = 0, j = 0;
	int v[32000];
	double ta, tb, t;
	monticulo maxHeap;

	printf("%s%12s%18s%19s%18s%18s\n", " ", "n", "t(n)", "t(n)/n^0.99",
			"t(n)/n^1.1 ", "t(n)/n^1.19");

	for (i = 0; i < 3; i++) {
		for (j = 2000; j < n; j = j * 2) {
			aleatorio(v, j);
			ta = microsegundos();
			ordenacion_por_monticulo(v, j);
			tb = microsegundos();
			t = tb - ta;
			if (t < UMBRAL) {
				t = tiemposUmbralOrdeMont(v, &maxHeap, j, aleatorio);
				cotas(t, j, pow(j, 0.99), pow(j, 1.1), pow(j, 1.19), 0);
			} else {
				cotas(t, j, pow(j, 0.99), pow(j, 1.1), pow(j, 1.19), 0); //t, n, f(n), h(n),g(n),T menores al umbral=1 SINO 0
			}
		}
		printf("\n");
	}
}
Exemple #5
0
int main(){
	int i,op;
	int N = 3;
	int vector[100];
	int *contador;
	
	contador = (int*)calloc(N,sizeof(int));//Asignado espacio de memoria
	if (contador == NULL){
		printf("No se ha podido asignar la memoria.\n");
	}
	else{
		aleatorio(vector, 100);
		for (i = 0; i < 100; i++){
			op = vector[i];
			*(contador + op) += 1; 
		}

		for (i = 0; i < N; i++){
			printf("%i ", *(contador + i));
		}
	}

	free(contador);

	system("pause");
	return 0;
}
void muestreo1000numeros(){

    /**
    * Programa que muestre por pantalla el resultado
    * de un muestreo de 1000 numeros aleatorios
    * comprendidos entre el 1 el 100
    **/

    int array[100];
    int n = 0;

    seed();

    for(int i = 0; i < 100; i++){
        array[i] = 0;
    }

    for(int i = 0; i < 999; i++){
        n = aleatorio(99);
        array[n] += 1;
    }

    for(int i = 0; i < 99; i++){
        if(array[i] != 0){
            printf("%d      --> %d  veces\n", i, array[i]);
        }
    }
}
Exemple #7
0
void Tuneado::avanza(Automovil* p) {
	int random = aleatorio(1,6);
	int distancia;
	distancia = this->distancia = this->distancia + random;
	if(distancia == p->getDistancia()){
		this->distancia = distancia + usarNitro();
	}
}
Exemple #8
0
int main(){
int a[8];
aleatorio(a,8);
imprimir(a,8);
printf("repite");
repite(a,8);

}
int cuenta(){
	int c;
	c=aleatorio();
	printf("c=f %d\n",c);
	if (c<25){
		return 1;
	}else
		return 0;
}
void llenarMatriz(int matriz[x][y]){
    int nAle = 0;
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            nAle = aleatorio(100);
            matriz[i][j] = nAle;
        }
    }
}
Exemple #11
0
int main(){

	int x;

	x = aleatorio(10);

	printf("%d\n", x);

	printf("\n\n");
}
Exemple #12
0
main(void)
{
	time_t inicio, fim;
	int i;
	double **A, **B, **C, D[TAM][TAM] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
	
	A = aleatorio();
	B = aleatorio();
	
	inicio=time(NULL);
	C = mult_matrizes2(A, D);
	fim=time(NULL);

	// Formato retornado pela asctime: DDD MMM dd hh:mm:ss YYYY
	//printf("The current time is %s\n",asctime(localtime(&inicio)));	
	printf("\nDiff tempo = %f\n", (double)(fim - inicio));
	printf("\nDiff tempo = %f\n", difftime(fim, inicio));
	
	remove_matriz(A);
	remove_matriz(B);
	remove_matriz(C);
}
Exemple #13
0
int main(int argc, char *argv[]){
	double inicio, fin = dsecnd();
	double *A = (double *)mkl_malloc(N*N*sizeof(double), 64);
	double *B = (double *)mkl_malloc(N*sizeof(double), 64);
	int *pivot = (int *)mkl_malloc(N*sizeof(int), 32);
	// distribucion normal de media 0 y varianza 1 
	std::default_random_engine generador;
	std::normal_distribution<double> aleatorio(0.0, 1.0);
	for (int i = 0; i < N*N; i++) A[i] = aleatorio(generador);
	for (int i = 0; i < N; i++) B[i] = aleatorio(generador);
	// matriz A marcadamente diagonal para evitar riesgo de singularidad 
	for (int i = 0; i < N; i++) A[i*N + i] += 10.0;
	int result;
	inicio = dsecnd();
	for (int i = 0; i < NTEST; i++)
		result = LAPACKE_dgesv(LAPACK_ROW_MAJOR, N, 1, A, N, pivot, B, 1);
	fin = dsecnd();
	double tiempo = (fin - inicio) / (double)NTEST;
	printf("Tiempo: %lf msec\n", tiempo*1.0e3);
	mkl_free(A);
	mkl_free(B);
	std::getchar(); return 0;
}
Exemple #14
0
void Patrulla::avanza(Automovil* t){
	int random = aleatorio(1,7);
	int distancia;
	distancia = this->distancia;
	if(distancia > t->getDistancia()){
		//No hace nada;
	} else if(distancia == t->getDistancia()-1) {
		chocar(t);
	} else{
		this->distancia = this->distancia + random;
	}

	//sonarSirena();
}
Exemple #15
0
int Tuneado::usarNitro() {
	int random = aleatorio(1,5);
	if(this->nitro != 0){
		if(random <= this->nitro){
				this->nitro = this->nitro - random;
		} else {
			int dif = this->nitro - random;
			random = random + (dif);
			this->nitro = this->nitro - random;
		}
	} else {
		random = 0;
	}

	return random;
}
int main(){
	int opcion;
	rand=(time(NULL))%100;
	printf("1- IGRESAR MANUALMENTE LOS DATOS\n");
	printf("2- IGRESAR AUTOMATICAMENTE LOS DATOS\n\n:");
	scanf("%d",&opcion);
	if(opcion == 1)
		ingresar();
	else
		aleatorio();
	pantalla();
	hordenamiento();
	pantalla();
	getchar();
	getchar();
}
Exemple #17
0
int main(int argc, char* argv []){
	int n, tipo;

	if(argc != 2){
		printf("Erro, número de argumentos inválidos!");
		exit(1);
	}
	//obtem o numero de elementos a serem gerados
	n = atoi(argv[1]);

	

	aleatorio(n);


	return 0;
}
Exemple #18
0
/**
 * The thread will begin control in this function.
 * Each thread will output its own version of "Hello World"
 */
void *runner(void *param) 
{
	int tam=1000;
	int vet[tam];
	double ti,tf,insert,qu,sh,he,se;
	struct timeval tempo_inicio, tempo_fim;
	aleatorio(vet,tam);
	//imprimir(vet,tam);
	gettimeofday(&tempo_inicio,NULL);
	Selecao(vet,tam);
	gettimeofday(&tempo_fim,NULL);
	//imprimir(vet,tam);
	tf =(double)tempo_fim.tv_usec+((double)tempo_fim.tv_sec*1000000);
	ti =(double)tempo_inicio.tv_usec+((double)tempo_inicio.tv_sec*1000000);
	se = (tf-ti);
	printf("|  Selecao  | %.0lf microsegundos \n",se);
	pthread_exit(0);
}
Exemple #19
0
void dialogo_alea(void)
{
    float min, max;

    printf("Ingrese el mínimo del rango \n");
    scanf("%f",&min);
    printf("Ingrese el máximo del rango \n");
    scanf("%f",&max);
    if(min > max)
    {
        printf("Error. Ha ingresado mal el intervalo");
    }
    else
    {
        printf("El Resultado es: %.4f \n",aleatorio(min, max));
    }

}
Exemple #20
0
int main(int argc, char* argv []){
	int n, tipo;

	if(argc != 3){
		printf("Erro, número de argumentos inválidos!");
		exit(1);
	}
	//obtem o numero de elementos a serem gerados
	n = atoi(argv[2]);

	
	if(strcmp(argv[1], "-a")==0)
		aleatorio(n);
	else if(strcmp(argv[1], "-c")==0){
		crescente(n);
	}
	else if (strcmp(argv[1], "-d")==0){
		descrescente(n);
	}

	return 0;
}
int pegue_palitos(struct jogad jogador[] , int num, int rodadas, int total_palitos )
{

    int i;
    int palitos;
    
    do { // pegar a quantidade de palitos do jogador humano
	
	// posicao inicial das mensagens
	i=18;
	JANELA2();
	
	POS (i++,5);
	printf ("Você possui [%d] palitos, há [%2d] palitos em jogo", jogador[0].tpalitos, total_palitos);
	
	POS (i++,5);
	printf ("Jogador, digite quantos palitos quer jogar, para sair [-1]: "); 
	
	// muda palitos antes do condicional,
	// isto previne sair do programa quando palitos == -1
	scanf("%d", &palitos);

	// caso se escolha -1, isto eh sair do jogo
	if ( palitos == -1) { 
	    tela_saida(); 	//mostra tela de saída
	    exit(0); 		//saí do jogo
	}	
	
	if ( (palitos < 0) || ( palitos > jogador[0].tpalitos) ) {
	    STATUS();
	    printf("Quantidade inválida de palitos");
	
	}
	;;

	if ((rodadas == 1) && (palitos == 0)) {
	    STATUS();
	    printf("Na primeira rodada a quantidade de palitos deve ser maior que 0");
	    palitos= -1; // para não sair no laço pois continue não funcionou
	}
	;;
	
    } while ( (palitos < 0) || ( palitos > jogador[0].tpalitos) );
    ;;
    
    jogador[0].palitos = palitos;    
    
    for (i = 1; i < num + 1; i++) {
	
	// gera um numero de palitos a jogar por numeros aleatorios 
	// inteligencia=0.
	jogador[i].palitos = aleatorio(jogador[i].tpalitos);
	
	
	if ((rodadas == 1) && (jogador[i].palitos == 0)) 
	    i--; // decrementa i para permanecer no mesmo jogador
	;;

    }
    ;;
    
    palitos = 0;
        
    for (i = 0; i <= num ; i++) 
	palitos += jogador[i].palitos; //total de palitos
    ;;    

    return(palitos);
    
}
Exemple #22
0
int hangman()
{
	/* numero de intentos (max 10)*/
	int intentos=0;
	char key='\b';
	char words[30][128] = {"ornitorrinco", "gato", "buho", "manzana", "aerogenerador", "arbol", "policia", "noviembre",
			     "carta", "entrada", "flor", "inteligencia", "chocolate", "literatura", "galleta", "movil",
			     "ordenador", "chimenea", "caramelo", "cucaracha", "mesa", "ardilla", "ventana", "llaves",
			     "ladrillo", "coche", "bombilla", "vino", "bicicleta", "atracciones"};
	char word[128];
	char fails[128];
	for (int w=0; w < 128; w++) {
		fails[w] = ' ';
	}
	int z=0;
	char str[] = {0x1b, 0x5b, 0x48, 0x1b, 0x5b, 0x4a, '\0'};
	int n = aleatorio();
	if (n > 29) {
		n = n / 2;
		if (n > 29) {
			n = n / 2;
		}
	}
	printf("%s", str);
	u16 *vga;
	MemoryMessage mem;

	/* Request VGA memory. */
	mem.action    = CreatePrivate;
	mem.bytes     = PAGESIZE;
	mem.virtualAddress  = ZERO;
	mem.physicalAddress = VGA_PADDR;
	mem.protection      = PAGE_RW | PAGE_PINNED;
	mem.ipc(MEMSRV_PID, SendReceive, sizeof(mem));

	/* Point to the VGA mapping. */
	vga = (u16 *) mem.virtualAddress;
	for (int i=0; i <= 127; i++) {
		word[i] = '_';
	}
	/* bucle principal del juego */
	while(1) {
		/* ponemos el color de fondo */
		for (int i=0; i <= 2000; i++) {
			vga[i] = VGA_CHAR(' ', BROWN, BROWN);
		}
		/*titulo de la ventana */
		window("AmayaOS Hangman", 2);
		/* cuadro de texto */
		for (int i=321; i >= 0; i++) {
			vga[i] = VGA_CHAR(' ', GREEN, GREEN);
			switch (i) {
				case 350:
					i = 400;
					break;
				case 430:
					i = 480;
					break;
				case 510:
					i = 560;
					break;
				case 590:
					i = -2;
					break;
			}
			for (int i=0; i < strlen(words[n]); i++) {
				vga[409+i] = VGA_CHAR(word[i], BLACK, GREEN);
			}
		}
		for (int i=361; i >= 0; i++) {
			vga[i] = VGA_CHAR(' ', GREEN, GREEN);
			if (i == 390 || i == 470 || i == 550 || i == 630 || i == 710 || i == 790 ||
			    i == 870 || i == 950 || i == 1030 || i == 1110 || i == 1190 || i == 1270 ||
			    i == 1350 || i == 1430 || i == 1510 || i == 1590 || i == 1670 || i == 1750 || i == 1830) {
				i = i+50;
			}
			if (i >= 1880) {
				i = -2;
			}
		}
		if (intentos >= 0) {
			vga[1572] = VGA_CHAR('-', BLACK, GREEN);
			vga[1573] = VGA_CHAR('-', BLACK, GREEN);
			vga[1574] = VGA_CHAR('-', BLACK, GREEN);
			vga[1575] = VGA_CHAR('-', BLACK, GREEN);
			vga[1576] = VGA_CHAR('-', BLACK, GREEN);
			if (intentos >= 1) {
				vga[1494] = VGA_CHAR('|', BLACK, GREEN);
				vga[1414] = VGA_CHAR('|', BLACK, GREEN);
				vga[1334] = VGA_CHAR('|', BLACK, GREEN);
				if (intentos >= 2) {
					vga[1254] = VGA_CHAR('|', BLACK, GREEN);
					vga[1174] = VGA_CHAR('|', BLACK, GREEN);
					vga[1094] = VGA_CHAR('|', BLACK, GREEN);
					if (intentos >= 3) {
						vga[1014] = VGA_CHAR('|', BLACK, GREEN);
						vga[934] = VGA_CHAR('|', BLACK, GREEN);
						vga[854] = VGA_CHAR('|', BLACK, GREEN);
						vga[855] = VGA_CHAR('/', BLACK, GREEN);
						vga[774] = VGA_CHAR('_', BLACK, GREEN);
						vga[775] = VGA_CHAR('_', BLACK, GREEN);
						vga[776] = VGA_CHAR('_', BLACK, GREEN);
						vga[777] = VGA_CHAR('_', BLACK, GREEN);
						if (intentos >= 4) {
							vga[857] = VGA_CHAR('|', BLACK, GREEN);
							if (intentos >= 5) {
								vga[937] = VGA_CHAR('O', BLACK, GREEN);
								if (intentos >= 6) {
									vga[1016] = VGA_CHAR('-', BLACK, GREEN);
									vga[1017] = VGA_CHAR('-', BLACK, GREEN);
									vga[1018] = VGA_CHAR('-', BLACK, GREEN);
									if (intentos >= 7) {
										vga[1097] = VGA_CHAR('|', BLACK, GREEN);
										if (intentos >= 8) {
											vga[1176] = VGA_CHAR('/', BLACK, GREEN);
											if (intentos >= 9) {
												vga[1178] = VGA_CHAR('\\', BLACK, GREEN);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		for (int i=0; i < 10; i++) {
			vga[1642+i] = VGA_CHAR(fails[i], BLACK, GREEN);
		}
		bar("PULSA [RETURN] PARA SALIR");
		key = getchar();
		if (key == '\b') {
			for (int w=0; w < 128; w++) {
				fails[w] = ' ';
			}
			return 0;
		}
		else {
			for (int i=0; i < strlen(words[n]); i++) {
				if (key == words[n][i]) {
					word[i] = key;
				}
			}
			for (int i=0, tf=0; i < strlen(words[n]); i++) {
				if (key == words[n][i]) {
					tf++;
				}
				if (i == strlen(words[n])-1 && tf == 0 && key != fails[0] && key != fails[1] && key != fails[2] && key != fails[3] && key != fails[4] && key != fails[5] && key != fails[6] && key != fails[7] && key != fails[8] && key != fails[9]) {
					intentos++;
					fails[z] = key;
					z++;
				}
			}
		}
		if (intentos > 10) {
			error("", "             GAME OVER", "");
			intentos=0;
			n = aleatorio();
			if (n > 5) {
				n = n / 2;
			}
			for (int i=0; i <= 127; i++) {
				word[i] = '_';
				fails[i] = ' ';
				z = 0;
			}
		}
		for (int i=0; i < strlen(words[n]) && word[i] != '_'; i++) {
			if (i == strlen(words[n])-1) {
				error("             YOU", "             WIN", "");
				intentos=0;
				n = aleatorio();
				if (n > 5) {
					n = n / 2;
				}
				for (int i=0; i <= 127; i++) {
					word[i] = '_';
					fails[i] = ' ';
					z = 0;
				}
			}
		}
	}

}
tabuleiro *aleatorio(tabuleiro *tab,int before){
	int lin,col,i,l,com=0,barexist,barconess, posicoes;
	int linhas[100],comb[100];
	char tmp[100][100],local[100][100];
	tabuleiro *f, *w, *z, *x;

	


	for(lin=0;lin!=tab->tamanho[0];lin++){
		barexist=0;
		posicoes=0;
		for(col=0;col!=tab->tamanho[1];col++){
			if(caniboat(tab,lin,col)) posicoes++;
			else if(tab->quadro[lin][col]!='~' && tab->quadro[lin][col]!='.') barexist++;
		}
		barconess=tab->linhas[lin]-barexist;
		comb[lin]=combinacoes(posicoes,barconess);
	}


	for(i=0;i!=tab->tamanho[0];i++)
		linhas[i]=i;



	ordena(comb,linhas,0,tab->tamanho[0]);



	for(i=0;comb[i]==0;i++);

	l=linhas[i];
	com=0;








	for(lin=0;lin!=tab->tamanho[0];lin++)
	   	for(col=0;col!=tab->tamanho[1];col++)
	   		tmp[lin][col]=tab->quadro[lin][col];


		do{
			if(verifica(tab)==2) ;
			else if(verifica(tab)==0){

				for(lin=0;lin!=tab->tamanho[0];lin++)
	   				for(col=0;col!=tab->tamanho[1];col++)
	   					tab->quadro[lin][col]=tmp[lin][col];

	   				++com;

					if(com>=comb[i]) {com=0; l=linhas[++i];}

	   				tab=aleoaux(tab,l,com);
	   			}

	  	    else if(verifica(tab)==1){

	  	    	++com;

				if(com>=comb[i]) {com=0; l=linhas[++i];}



	  	    	tab=aleoaux(tab,l,com);
	  	    } 			

			do{
				for(lin=0;lin!=tab->tamanho[0];lin++)
	   				for(col=0;col!=tab->tamanho[1];col++)
	   					local[lin][col]=tab->quadro[lin][col];
	   	

        	f=aloca(tab);
        	w=verigual(tab,estra1(f));


        	f=aloca(w);
        	z=verigual(w,estra2(f));


        	f=aloca(z);
        	x=verigual(z,estra3(f));

        	f=aloca(x);
        	tab=verigual(x,estra4(f));



		}while(changes(local,tab) && verifica(tab)!=2);


		if(verifica(tab)==0){
			for(lin=0;lin!=tab->tamanho[0];lin++)
	   				for(col=0;col!=tab->tamanho[1];col++)
	   					tmp[lin][col]=tab->quadro[lin][col];

		}




		if(before==1){
			for(lin=0;lin!=tab->tamanho[0];lin++)
	   				for(col=0;col!=tab->tamanho[1];col++)
	   					tmp[lin][col]=tab->quadro[lin][col];

	   	return tab;

		}
		else if(verifica(tab)!=2 && i+1==tab->tamanho[0]) tab=aleatorio(tab,1);

		if(dots(tab) || verifica(tab)!=2) {
			for(lin=0;lin!=tab->tamanho[0];lin++)
	   				for(col=0;col!=tab->tamanho[1];col++)
	   					tmp[lin][col]=tab->quadro[lin][col];

	   	return tab;

		}

	}while(verifica(tab)!=2);


   return tab;
}
Exemple #24
0
/* Retorna um valor aleatório entre 0 e 10. */
float nota_aleatoria() {
  return aleatorio(11);
}
Exemple #25
0
int main()
{
    printf("%s", aleatorio(10));
    getchar();
    return 0;
}
Exemple #26
0
int juego()
{
    /*Generamos el numero misterioso*/
    int numero = aleatorio();
    int intentos = 0;

    char talvezs[128];
    int talvez = 0;
    char qidn;
    int np_1 = numero - num1(1);
    int np_2 = numero + num1(2);


    if (np_1 < 0) {
	np_1 = 0;
    }
    if (np_2 > 100) {
	np_2 = 100;
    }

    do
    {
        limpiar();
        printf("Has hecho %d intentos.\n", intentos);
        printf("El numero misterioso esta entre %d y %d.\n\n", np_1, np_2);
	printf("Escribe 'e' para cerrar\n");

        printf("Tu propuesta: ");
	/* gets_s() es un fork de gets() que arregla sus fallos de seguridad */
        gets_s(talvezs, 128);
	if (talvezs[0] == 'e') {
	  limpiar();
    	  printf("Bye !\n");
	  return 0;
	}
	talvez = atoi(talvezs);
	

        intentos = intentos + 1;
    }while(talvez != numero);

    /*Adivino el numero !*/

    limpiar();
    printf("=== FELICIDADES ===\n");
    printf("  === GANASTE ===\n\n");
    printf("El numero era: %d\n\n", numero);
    printf("Lo intentaste: %d veces\n", intentos);
    printf("Quieres volver a jugar ? (S/n): ");
    qidn = getchar();
    putchar(qidn);

    if(qidn == 'S' || qidn == 's')
    {
        limpiar();
        juego();
    }
    else if(qidn == 'N' || qidn == 'n')
    {
        limpiar();
        menu();
    }
    else
    {
        limpiar();
        menu();
    }
    return 0;
}