mardi 31 mars 2015

Any idea to exit FOR and print a message


int liContador1, liContador2, liElse = 0;

for (liContador1 = 1; liContador1 <= liNumeroB; liContador1++)
{
for (liContador2 = liContador1 + 1; liContador2 <= liNumeroB; liContador2++)
{
if (NumerosAmigos(liContador1, liContador2))
printf("\n%d, %d", liContador1, liContador2);

else
liElse++; **or what can i do?**
}
}

if (liElse != 0)
printf("\nThe numbers are not friends.\n");


I'm making a program to search the previous amicable numbers to a given value. The program prints the pair of numbers found but need to display a message if no pair of amicable numbers.


The problem is that I can not think on way to do it. I tried with BREAK, continiue, ACCOUNTANTS ..


This is what i was trying:



else
liElse++;


Anyone have any ideas on how I can do to solve this ?.


Greetings and thank you all for helping !.


Aucun commentaire:

Enregistrer un commentaire