Здравствуйте! Нужна помощь! необходимо написать цикл с постпроверкой и цикл с предпроверкой в Lazarus или в Delphi, особой разницы нет!
Код:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Grids, Spin;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
FloatSpinEdit1: TFloatSpinEdit;
FloatSpinEdit2: TFloatSpinEdit;
FloatSpinEdit3: TFloatSpinEdit;
FloatSpinEdit4: TFloatSpinEdit;
FloatSpinEdit5: TFloatSpinEdit;
FloatSpinEdit6: TFloatSpinEdit;
Label2: TLabel;
Label3: TLabel;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpinEdit1Change(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
i,max:integer;
a:array[1..10]of real;
begin
for i:=1 to form1.StringGrid1.RowCount-1 do
a[i]:=StrToFloat(StringGrid1.Cells[7,i]);
max:=1;
for i:=1 to form1.StringGrid1.RowCount-1 do
if a[i]> a[max]then max:=i;
label2.caption:='Лучший результат: '+floatToStr(a[max])
+#13+'Номер пары: '+ IntToStr(max);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
end;
procedure TForm1.Button4Click(Sender: TObject);
var
m:real;
begin
form1.StringGrid1.RowCount:=form1.StringGrid1.RowCount+1;
form1.StringGrid1.Cells[0,form1.StringGrid1.RowCount-1]:=inttostr(form1.StringGrid1.RowCount-1);
form1.StringGrid1.Cells[1,form1.StringGrid1.RowCount-1]:=floattostr(floatSpinEdit1.Value);
form1.StringGrid1.Cells[2,form1.StringGrid1.RowCount-1]:=floattostr(floatSpinEdit2.Value);
form1.StringGrid1.Cells[3,form1.StringGrid1.RowCount-1]:=floattostr(floatSpinEdit3.Value);
form1.StringGrid1.Cells[4,form1.StringGrid1.RowCount-1]:=floattostr(floatSpinEdit4.Value);
form1.StringGrid1.Cells[5,form1.StringGrid1.RowCount-1]:=floattostr(floatSpinEdit5.Value);
form1.StringGrid1.Cells[6,form1.StringGrid1.RowCount-1]:=floattostr(floatSpinEdit6.Value);
m:=floatspinEdit1.Value+floatspinEdit2.Value+floatspinEdit3.Value
+floatspinEdit4.Value+floatspinEdit5.Value+floatspinEdit6.Value;
form1.StringGrid1.Cells[7,form1.StringGrid1.RowCount-1]:=floattostr(m);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.StringGrid1.Cells[0,0]:='№';
form1.StringGrid1.Cells[1,0]:='Судья 1';
form1.StringGrid1.Cells[2,0]:='Судья 2';
form1.StringGrid1.Cells[3,0]:='Судья 3';
form1.StringGrid1.Cells[4,0]:='Судья 4';
form1.StringGrid1.Cells[5,0]:='Судья 5';
form1.StringGrid1.Cells[6,0]:='Судья 6';
form1.StringGrid1.Cells[7,0]:='Результат';
end;
procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
end;
initialization
{$I unit1.lrs}
end.