连通图(深搜)
题意
判断一个图是否为一个边通图
分析
这题我用深搜来做
var
n,x,y,tj:longint;
a:array[0..101,0..101]of longint;
f:array[0..101]of longint;
procedure dfs(i:longint);
var
j:longint;
begin
for j:=1 to n do
if (f[j]=0)and(a[i,j]=1) then
begin
f[j]:=1;
inc(tj);
dfs(j);
end;
end;
begin
readln(n);
fillchar(a,sizeof(a),0);
fillchar(f,sizeof(f),0);
while not eoln do
begin
readln(x,y);
a[x,y]:=1;
a[y,x]:=1;
end;
tj:=0;
dfs(1);
if tj=n then write(1) else write(0);
end.