题目:
1233 |
1 #include2 #include 3 #include 4 #include 5 using namespace std; 6 7 #define M 101 8 typedef struct{ 9 int x,y;10 int len;11 }EDGE;12 13 EDGE edge[M*M];14 int Map[M][M];15 int n,m;16 int set[M];17 18 void ReadMap();19 void InitSet();20 int cmp(const EDGE &a,const EDGE &b);21 int FindSet(int a);22 void MergeSet(int a,int b);23 void main()24 {25 int c,s,f,t;26 while (scanf("%d",&n),n)27 {28 m = (n*(n-1))>>1;29 ReadMap();30 InitSet();31 c = 0;//choosed node32 s = 0;//sum length33 sort(edge,edge+m,cmp);//sort the edges34 for (int i=0;i >edge[i].x>>edge[i].y>>edge[i].len;53 }54 void InitSet()55 {56 for (int i=1;i<=n;i++)57 set[i] = i;58 }59 int cmp(const EDGE &a,const EDGE &b)60 {61 return a.len