Como puedo saber cuantos nъmeros faltan?
#1

Hola compaсeros de fs, bueno tengo una duda en cuanto a un bucle...

He hecho esto:
pawn Код:
new variable;
main()
{
    for(new e = 0; e < 11; e++)
    {
        if(e == 1){ variable --; continue;}
        else
        {
        variable++;
            printf("%d", e);
            printf("%d variable",variable);
            if(variable < e) print("falta un numero");
        }
    }
}
Funciona correctamente y me dice que falta un nъmero, ahora mi duda es: como puedo hacer para saber cuantos nъmeros faltan? osea cuales fueron los nъmeros que continue; se ha saltado, o por lo menos saber cuantos nъmeros se salto, gracias.
Reply
#2

Код:
new variable,
falto,
cantidad_faltantes;
main()
{
	for(new e = 0; e < 11; e++)
	{
	    if(e == 1){ variable --;  continue; falto = e; cantidad_faltantes++; }
	    else
	    {
		variable++;
	    	printf("%d", e);
	    	printf("%d variable",variable);
	    	if(variable < e) {  print("falta un numero"); printf("falto el numero %d, cantidad de numeros faltantes %d", falto, cantidad_faltantes); }
	    }
  	}
}
Reply
#3

Quote:
Originally Posted by OTACON
Посмотреть сообщение
Код:
new variable,
falto,
cantidad_faltantes;
main()
{
	for(new e = 0; e < 11; e++)
	{
	    if(e == 1){ variable --;  continue; falto = e; cantidad_faltantes++; }
	    else
	    {
		variable++;
	    	printf("%d", e);
	    	printf("%d variable",variable);
	    	if(variable < e) {  print("falta un numero"); printf("falto el numero %d, cantidad de numeros faltantes %d", falto, cantidad_faltantes); }
	    }
  	}
}
Muchas gracias.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)