AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Stack-Überlauf :-(

Ein Thema von vogael · begonnen am 30. Aug 2006 · letzter Beitrag vom 4. Sep 2006
 
vogael

Registriert seit: 13. Sep 2005
15 Beiträge
 
#1

Stack-Überlauf :-(

  Alt 30. Aug 2006, 22:10
Hallo, bei einem kleinen Programm, welches Bubblesorten soll, tritt immer ein Stack-Überlauf auf, wenn eine Liste mit Zufallszahlen oder eine sortierte Liste von 0-x erstellt wird, welche danach sortiert werden soll. Bei einer invertiert sortierten jedoch nicht. Woran liegt das? Hier mal der Quelltext von dem Listen-Erstell-Button :-O also bei case...of 0 und 2 kommt ein Stacküberlauf, 1 geht reibungslos....
sorry für den nicht sehr eleganten Quelltext

Delphi-Quellcode:
lol:=true;
Anzahl:=StrToInt(EdtAnzahl.text);
SetLength(wert,Anzahl);
ListBox1.Clear;ListBox2.clear;
case cbxvorlage.itemindex of
   0:

   begin
   for i:=0 to Anzahl-2 do
       begin
       wert[i]:=i;
       end;
   randomize;
   Zufallszahl:=random(Anzahl);
   wert[anzahl]:=Zufallszahl;
   for i:=0 to Anzahl-1 do
       begin
       if lol=true then
       ListBox1.Items.Add(IntTostr(wert[i]));
       if checkbox1.checked=true then
          begin
          if i>499 then lol:=false;
          end;
       end;
   end;

1:
   begin
   for i:=0 to Anzahl-1 do
   wert[i]:=Anzahl-i;
   for i:=0 to Anzahl-1 do
       begin
       if lol=true then
       ListBox1.Items.Add(IntTostr(wert[i]));
       if checkbox1.checked=true then
          begin
          if i>499 then lol:=false;
          end;
       end;
   end;

2:
   begin
   randomize;
   for i:=1 to anzahl do
   wert[i]:=random(anzahl);
   for i:=0 to Anzahl-1 do
       begin
       if lol=true then
       ListBox1.Items.Add(IntTostr(wert[i]));
       if checkbox1.checked=true then
          begin
          if i>499 then lol:=false;
          end;
       end;

   end;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:20 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz