摘要:
#include<stdio.h>#include<stdlib.h>#define N 30000#define M 500int rank[N], father[N],num[N]; /* rank指代数的层数,num指每个节点数目 */ int Make_set(int x) /* 初始化父节点 */{ int i; for (i=0; i<x; i++) { father[i] = i; rank[i] = 0; num[i] = 1; }}int Find_set(int x) /* 寻找父节点,运用递归查找 */{ if (x != father[x] 阅读全文
摘要:
#include<stdio.h>#include<stdlib.h>#include<string.h>#define INT_MAX 2500typedef struct{ int x, y; int w;}edge;edge e[INT_MAX];int rank[INT_MAX], father[INT_MAX], dis_sum;int cmp(const void *a,const void *b){ return (*(edge*)a).w > (*(edge*)b).w ? 1 : -1;}int Exchage(int n){ int 阅读全文