Pagini recente » Cod sursa (job #1597693) | Cod sursa (job #3291368) | Cod sursa (job #2726502) | Cod sursa (job #2058535) | Cod sursa (job #273467)
Cod sursa(job #273467)
program pascal;
var f,g:text; a:array[1..30000,1..25000] of byte;
i,j,x,y,n,m,k:longint; s:array[0..50000] of byte;
procedure citire;
begin
assign(f,'sortaret.in'); reset(f);
assign(g,'sortaret.out'); rewrite(g);
readln(f,n,m);
k:=0;
for i:=1 to m do
begin
readln(f,x,y);
a[x,y]:=1; a[y,x]:=1;
end;
end;
procedure df(nod:longint);
var j:longint;
begin
write(g,nod,' ');
s[nod]:=1;
for j:=1 to n do
if (s[j]=0) and (a[nod,j]=1) then df(j);
end;
begin
citire;
for i:=1 to n do
if s[i]=0 then df(i);
close(f);
close(g);
end.