上一页 1 ··· 12 13 14 15 16
摘要: #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] 阅读全文
posted @ 2011-08-14 10:35 zhongya 阅读(139) 评论(0) 推荐(0) 编辑
摘要: #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 阅读全文
posted @ 2011-08-13 10:35 zhongya 阅读(200) 评论(0) 推荐(1) 编辑
上一页 1 ··· 12 13 14 15 16