Autor Beitrag
Jeanpy
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Mo 03.04.06 09:08 
Ich brauche noch hilfe. Und zwar muss ich in mein Sortierprogramm (Quelltext folgt) eine Grafik einbauen nur weiß ich leider nicht was ich für eine machen soll und wie ich sie einbaue. Ich wäre euch sehr verbunden wenn ihr mir ein wenig helfen könntet. Danke schonmal im Vorraus.
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
unit Unit1;

 
interface  

 
uses  
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  
  Dialogs, StdCtrls;  

 
type  
  TForm1 = class(TForm)  
    Button1: TButton;  
    Button2: TButton;  
    Edit1: TEdit;  
    Memo1: TMemo;  
    Label1: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);  
    procedure Button2Click(Sender: TObject);  
  private  
    { Private-Deklarationen }  
  public  
    { Public-Deklarationen }  
  end;  

 
const  
max = 100;  

 
var  
wert: array [1..max]of integer;  
Randomzahlen: integer;  
Form1: TForm1;  

 
implementation  

 
{$R *.dfm}  

 
procedure TForm1.Button1Click(Sender: TObject);  

 
var  
i:integer;  

 
begin  
 randomize;  
 i:=0;  
 Randomzahlen:=(strtoint(Edit1.Text));  
 for i:=1 to Randomzahlen do  

 
begin  
 wert[i]:= Random(max)+1;  
 Memo1.Lines.Add(inttostr(wert[i]));  
 end;  
end;  




procedure TForm1.Button2Click(Sender: TObject);     
var     
  a, b: Integer;     
  swap: String;  
begin     
  for a := 1 to Randomzahlen do     
    for b := a + 1 to Randomzahlen do  
      if StrToInt (memo1.lines[a]) < StrToInt (memo1.lines[b]) then     
        begin  
          swap := memo1.lines[a];
          memo1.lines[a] := memo1.lines[b];  
          memo1.lines[b] := swap; 
 
        end;  
end; 


 
end.


Zuletzt bearbeitet von Jeanpy am Mo 03.04.06 10:13, insgesamt 2-mal bearbeitet
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 03.04.06 09:22 
Sortierverfahren mit Source findest du bei den Delphi-Beispielen zu Threads. Dort werden drei Verfahren gezeigt mit Grafik.
Vielleicht ist das ja schon genau das, was du meintest.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 03.04.06 09:31 
Sortierverfahren sind z.B. Bubblesort, Quicksort, Heapsort, Sortieren durch Auswahl, Sortieren durch Einfügen. Eine Suche danach sollte einiges zu Tage fördern ;-)

Zu deinem Programm: Überarbeite das nochmal. Da ist einiges nicht richtig in Ordnung. Besonders solltest du darüber nachdenken, das es besser wäre, wenn man nur ein Array nimmt und darin die Elemente vertauscht, anstatt sie von einem Array ins andere zu kopieren.

_________________
We are, we were and will not be.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 03.04.06 10:34 
Moin!

Hmm, meinst du sowas, oder wie? :gruebel:

cu
Narses
Einloggen, um Attachments anzusehen!