Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var i,j:byte;
sum:real;
Begin
sum:=0;
For i:=0 to 3 do
For j:=0 to 5 do
sum:=sum + StrToFloat(StringGrid1.Cells[i,j]);
begin
ShowMessage(FloatToStr(sum));
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Close
end;
end.
Результаты
Блок-схема
Procedure Tform1.Button1Click(Sender:TObject)
Начало
Sum=0
For i=0 to 3 do
For i=0 to 5 do
sum:=sum + StrToFloat(StringGrid1.Cells[i,j])
Sum
Конец
Лабораторная работа № 5
Цель работы
Изучить компоненты CheckBox, SpinEdit.
Программа работы
Используя компоненты CheckBox, SpinEdit, написать программу для соответствующего варианта (номер определяется преподавателем).
Задание
Дан файл f, содержащий информацию о плоских геометрических телах: наименование, площадь, периметр, длина наибольшей стороны. Вывести данные о плоских геометрических телах, которые:
а) имеют площадь не более 50 см2 и периметр не менее 30 см;
б) имеют периметр не более 50 см и длину наибольшей стороны не менее 15 см;
в) имеют длину наибольшей стороны не более 20 см и площадь не менее 100 см2.
Текст программы
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Spin;
type
IntType = Integer;
RealType = Real;
TypeTR = Record
Name: String[6];
S : RealType;
P : RealType;
L : RealType;
end;
TP = Array[1..20] of TypeTR;
TL = Array[1..20] of IntType;
TForm1 = class(TForm)
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
SpinEdit3: TSpinEdit;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1 : TForm1;
N : IntType;
TR : TP;