Thema: Prism Min-Sort Verfahren

Einzelnen Beitrag anzeigen

cobi23

Registriert seit: 25. Feb 2013
12 Beiträge
 
#13

AW: Min-Sort Verfahren

  Alt 4. Mär 2013, 12:48
Danke für die Antwort, jetzt kommt aber bei mir diese Fehlermeldung:

"uselect.pas(73,7) Fatal: Syntax error, ";" expected but "identifier ZA" found
"

Code:
unit USelect;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Memo1: TMemo;
    Memo2: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
    za: array [1..20] of integer;
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  close;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i,x,y,k:Integer;
  begin
    memo1.Clear; memo2.Clear;
    for I:= 1 to 20 do za[i] :=i;
    for I:= 1 to 20 do
    begin
      x:=Random(20-i)+1;
      y:=za[i];
      za[i]:=za[x];
      za[x]:=y;
      for k:= 1 to 20 do
      memo1.Lines.Add(inttostr(za[i]));
    end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var i,j,m,x:integer;
  begin
  for I:= 1 to 20 do
  begin
    x:=i;
    for j:=i+1 to 20 do
    if za[x] > za[j] then
    x:=j;
    begin
      m:=za[x]
      za[x] := za [i];
      za[i] := m;
      end;
    memo2.Lines.Add(inttostr(za[i]));
    end;
  end;
end;

procedure TForm1.FormCreate(Sender:TObject);
begin
randomize;
end;

end.
  Mit Zitat antworten Zitat