У меня в нижеприведенном коде неправильное условие, его нужно исправить, но я не знаю как, сколько не думал-ничего путного не выходило!! Помогите начинающему программисту.Буду благодарен любой помощи.
Вот код:
Код: Выделить всё
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Memo1: TMemo;
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type TE=real;
spisok=^item;
item=record
v:spisok;
g:TE
end;
var
L,M,C:spisok;
i:Integer;
q:boolean;
procedure TForm1.Button1Click(Sender: TObject);
procedure Element(var L:spisok);
begin
q:=false;
L:=L^.v;
while (L<>nil) and (q=false) do
begin
if L^.g<M^.g then begin
L:=L^.v;
end
else q:=true;
end;
case q of
false:Label2.Caption:='Не упорядочены';
true:Label2.Caption:='Упорядочены';
end;
end;
begin
M:=nil;
for i:=0 to Memo1.Lines.Count-1 do
begin
new(L);
L^.g:=StrToFloat(Memo1.Lines[i]);
L^.v:=M;
M:=L
end;
Element(L);
end;
end.