刚开始自学算法,连通问题的快速查找算法中一句话看不懂,求解答,谢谢
程序代码:
#include <stdio.h> #define N 10000 int main(void) { int i, p, q, t, id[N]; for (i = 0; i < N; i++) id[i] = i; while (scanf("%d %d\n", &p, &q)==2) { if (id[p] == id[q]) continue; for (t = id[p], i = 0; i < N; i++) if (id[i] == t) id[i] = id[q]; printf(" %d %d\n", p, q); } return 0; }
下面这句话怎么理解:
scanf("%d %d\n", &p, &q)==2
等于2什么意思????