im Rahmen unseres Unterrichtes sollen wir ein BACKTRACKING Problem lösen !
Nun wollte ich in einer Funktion Prüfen ob etwas funktioniert (mit Boolean)!
Ich habe es wie Folgt gemacht:
Code: Alles auswählen
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
ListBox1: TListBox;
ListBox2: TListBox;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Feld_frei(a,b:integer;VAR t:Boolean);
private
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var i,a,b:integer;
begin
For i:=0 to 7 do
begin
ListBox1.Items[i]:=inttostr(0);
ListBox2.Items[i]:=inttostr(0);
end;
For a:=0 to 7 do
begin
For b:=0 to 7 do
begin
if Feld_frei(1,1)= true then
Begin
StringGrid1.Cells[b,a]:='D';
ListBox1.Items[a]:=InttoStr(a);
ListBox2.Items[b]:=InttoStr(b);
end;[code=laz]
StringGrid1.Cells[ListBox1.Items,ListBox2.Items[a]]:='';
end;
end;
end;
procedure Feld_frei(a,b:integer;VAR t:Boolean);
Var s,z:integer;
Begin
t:= True;
end;
end.[/code]
Der Wichtige Teil ist :
Code: Alles auswählen
procedure Feld_frei(a,b:integer;VAR t:Boolean);
Var s,z:integer;
Begin
t:= True;
end;
Bitte helft mir !
MfG SRB