błędy

0

kod źródłowy:
procedure TForm1.FormCreate(Sender: TObject);
var i,j: integer;
begin
 a:=20; b:=1; c:=1; w:=0;
 for i:=1 to a do
    for j:=1 to a do
       if i=j then t[i,j]:='x'
            else t[i,j]:='0';
 Label1.Caption:='0';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   a:=StrToInt(Label1.Caption);
   if a>20 then exit else Inc(a);
   Label1.Caption:=IntToStr(a);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   a:=StrToInt(Label1.Caption);
   if a<=0 then exit else Dec(a);
   Label1.Caption:=IntToStr(a);
end;

procedure TForm1.Button3Click(Sender: TObject);
var i,j:Integer;
begin
Label11.Visible:=true;
Label12.Visible:=true;
Label4.Visible:=true;
label13.Visible:=false;
label14.Visible:=false;
b:=1; c:=1;
Label7.Caption:='1';
Label9.Caption:='1';
Label10.Caption:='';
label4.Caption:='';
Label11.Caption:='';
Label12.Caption:='';
for i:=1 to a do
begin
 if i<10 then Label11.Caption:=Label11.Caption+'v'+IntToStr(i)+'  '
          else Label11.Caption:=Label11.Caption+'v'+IntToStr(i)+' ';
end;
for i:=1 to a do Label12.Caption:=Label12.Caption+'v'+IntToStr(i)+#10;
   for i:=1 to a do
      for j:=1 to a do
         begin
           if j<10 then  Label4.Caption:=Label4.Caption+'  '+ t[i,j]+'  '
                    else Label4.Caption:=Label4.Caption+'    '+ t[i,j]+' ';
            if j=a then Label4.Caption:=Label4.Caption+#13+#10;
         end;

end;

procedure TForm1.Button4Click(Sender: TObject);
begin
inc(b);
if b>a then b:=a;
Label7.Caption:=IntToStr(b);
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
dec(b);
if b<1 then b:=1;
Label7.Caption:=IntToStr(b);
end;


procedure TForm1.Button6Click(Sender: TObject);
begin
 inc(c);
if c>a then c:=a;
Label9.Caption:=IntToStr(c);
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
dec(c);
if c<1 then c:=1;
Label9.Caption:=IntToStr(c);
end;



procedure TForm1.Button8Click(Sender: TObject);
begin
if b<>c then begin
t[b,c]:='1'; t[c,b]:='1';
Label10.Caption:='1';
end;
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
if b<>c then begin
t[b,c]:='0'; t[c,b]:='0';
Label10.Caption:='0';
end;
end;

procedure TForm1.Button10Click(Sender: TObject);
var i,j:integer;
begin
randomize;
for i:=1 to a do
  for j:=1 to a do
    begin
    if i<>j then t[i,j]:=IntToStr(random(2));
    t[j,i]:=t[i,j];
    end;
end;

procedure TForm1.Button11Click(Sender: TObject);
var i,j,ikolor:integer; tabks,tk:tkolory;
begin
Label13.Caption:='';
for i:=1 to a do tk[i]:=0;
nkolory:=0;
for i:=1 to a do
  begin
  tabks[i]:=0;
  for j:=1 to i-1 do
    begin
    b:=i; c:=j;
    if t[b,c]='1' then tabks[tk[j]]:=1;
    end;
    ikolor:=1;
    while (ikolor<=a) and (tabks[ikolor]<>0) do inc(ikolor);
    tk[i]:=ikolor;
    if nkolory<ikolor then nkolory:=ikolor;
  end;
Label11.Visible:=false;
Label12.Visible:=false;
Label4.Visible:=false;

  Label13.Visible:=true;
for i:=1 to a do
  begin
  Label13.Caption:=Label13.Caption+'wierzcholek '+IntToStr(i)+' ma kolor'+IntToStr(tk[i])+#10;
  end;
end;

Procedure Odwiedz(a:integer; k:TypWezla;var o:odwiedzeni; var w:integer; t:tab);
Var
  j,l,v : integer;  r:boolean;
Begin
r:=false;
  inc(w);
  o[w]:=k;
  for j:=1 to a do
    begin
    if (t[i,j]='1') then
      begin
      for l:=1 to a do
        begin
        if o[l]=j then r:=true;
        end;
      if r=false then
            begin
            v:=j;
             odwiedz(a,v,o,w,t);
            end;
      end;
    end;
End;

procedure TForm1.Button12Click(Sender: TObject);
Var  i, j: TypWezla;    r:boolean;
Begin
label4.Caption:='';
w:=0;
For i:=1 To a Do o[i]:=0;
  For i:=1 To a Do
  begin
   For j:=1 To a Do begin
                    If o[j]=i Then r:=true;
                    end;
   if r=false then odwiedz(a,i,o,w,t);
  end;
  for i:=1 to a do
  Label14.Caption:=Label14.Caption+'v'+IntToStr(o[i])+' ';
  Label14.visible:=true;
end;




procedure TForm1.Button14Click(Sender: TObject);
begin
for i:=1 to a do
  for j:=1 to a do
    if i<>j then t[i,j]:='0';
end;

procedure odwiedzk(var j:integer; var o:odwiedzeni; t:tab; var w,ww:integer);
var r:boolean;  l,f:integer;
begin
r:=false;
for i:=1 to a do if o[i]=j then r:=true;
if r=false then begin
                 inc(ww);
                 o[ww]:=i;
                end;
r:=false;
for l:=1 to a do
  begin
  r:=false;
  if t[j,l]='1' then
            begin
            for f:=1 to a do
              begin
              if o[f]=l then r:=true;
              end;
            if r=false then odwiedzk(l,o,t,w,ww);
            end;

  end;

end;
procedure TForm1.Button13Click(Sender: TObject);
var r:boolean;
begin
Label14.Caption:='';
Label14.visible:=true;
w:=0;
for i:=1 to a do
  begin
  o[i]:=0;
  kl[i]:=0;
  end;
i:=1;
r:=false;
while i<=a do
  begin
  r:=false;
  for j:=1 to a do
            begin
            if o[j]=i then r:=true;
            end;
  if r=false then begin
                  inc(w);
                  kl[w]:=i;
                  end;
  r:=false;
  for j:=1 to a do
        begin
        if kl[j]<>0 then
    begin
    kl[w]:=0;
    odwiedzk(j,o,t,w,ww);
    end;
  end;
end;
for i:=1 to a do Label14.Caption:=Label14.caption+'v'+IntToStr(o[i])+'  ';
end;

end.

co zrobić? klepnij na button + pod napisem wierzcholki potem button losuj następnie BSF
wyskakuje błąd stack overflow, co to znaczy i jak mam temu zaradzić?
0

odwiedzk() i Odwiedz() to rekurencje i to one wywalają ci stos.

przeciwdziałanie (dobierz sobie rozmiary wg potrzeb):
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}

// http://4programmers.net/Forum/viewtopic.php?id=44030&p=15
// post wolverina i dalszy wasyla... uzywaj tagow tylko do kodów zródłowych

// Spin a czemu ty w ogóle nie odpowiadasz na temat ?

0

po co wklejasz cały kod - wklej tylko procedure, w której pojawia sie bład - i nie pisz 'kliknij na button "+" ' - skad mam wiedzieć, który z nich ma caption "+".... jak koniecznie musisz, to wrzuć cały projekt na jakieś www i podaj linka...

1 użytkowników online, w tym zalogowanych: 0, gości: 1