来自本人百度空间 2009-08-20 16:47
program krusdal(input,output);
var
g:array[1..100,1..100] of integer;
l:array[0..100] of integer;
u:array[0..100] of boolean;
n,i,j,k,total:integer;
begin
assign(input,'wire.in');
reset(input);
assign(output,'wite.out');
rewrite(output);
readln(n);
for i:=1 to n do begin
for j:=1 to n do read(g[i,j]);
readln;
end;
fillchar(l,sizeof(l),$7F);
l[1]:=0;
fillchar(u,sizeof(u),1);
for i:=1 to n do begin
k:=0;
for j:=1 to n do
if u[j]and (l[j]<l[k]) then k:=j;
u[k]:=false;
for j:=1 to n do
if u[j] and (g[k,j]<l[j]) then l[j]:=g[k,j];
end;
total:=0;
for i:=1 to n do inc(total,l[i]);
writeln(total);
close(output);
end.
是一个题目~~