Hi everyody!
So, my teacher gave me this program that implements the normal quick find but I don't seem to understand those two for lines in the program... what do they do? why do they have a ";" at the end?
Thanks everybody :)Code:#include <stdio.h>#define N 10000
main()
{
int i, j, p, q, id[N];
for(i=0; i<N; i++)
id[i] = i;
printf("Input pair p q: ");
while (scanf("%d %d", &p, &q) ==2)
{
for (i = p; i!= id[i]; i = id[i]);
for (j = q; j!= id[j]; j = id[j]);
if (i == j)
printf("pair %d %d already connected\n", p,q);
else
{
id[i] = j;
printf("pair %d %d not yet connected\n", p, q);
}
printf("Input pair p q: ");
}
system("pause");
}