C language source code: [cpp] # include <stdio. h> # include <stdlib. h> # include <math. h> # define maxsize 110 typedef struct edge {int a, B; double len;} edge; edge E [maxsize * (maxsize-1)/2]; int Tree [maxsize * (maxsize-1)/2]; int findroot (int x) {int temp; if (Tree [x] =-1) return x; else {temp = findroot (Tree [x]); Tree [x] = temp; return temp;} int cmp (const void * a, const void * B) {struct edge * aa = (edge *) a; struct edge * bb = (Edge *) B; return aa-> len> bb-> len? 1:-1;} int main () {int n, I, j, top, roota, rootb; double point [maxsize] [2], min; while (scanf ("% d", & n )! = EOF) {for (I = 0; I <n; I ++) scanf ("% lf", & point [I] [0], & point [I] [1]); top = 0; for (I = 0; I <n-1; I ++) {for (j = I + 1; j <n; j ++) {E [top]. a = I; E [top]. B = j; E [top]. len = sqrt (point [I] [0]-point [j] [0]) * (point [I] [0]-point [j] [0]) + (point [I] [1]-point [j] [1]) * (point [I] [1]-point [j] [1]); top ++ ;}} qsort (E, top, sizeof (E [0]), cmp); for (I = 0; I <top; I ++) tree [I] =-1; min = 0; for (I = 0; I <top; I ++) {www.2cto.com roota = findroot (E [I]. a ); Rootb = findroot (E [I]. B); if (roota! = Rootb) {Tree [rootb] = roota; min + = E [I]. len;} printf ("%. 2lf \ n", min );}}