Здравствуйте, нужна помощь! Помогите составить блок-схему программы написанной в среде Delphi по следующему коду!
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, Menus;
type
TForm1 = class(TForm)
Edit1: TEdit;
StringGrid1: TStringGrid;
Edit2: TEdit;
Edit3: TEdit;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
Button1: TButton;
StringGrid4: TStringGrid;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Type TArray = record
Col:integer;
V:array[0..50] of double;
end;
var
Form1: TForm1;
A,B,C,D:TArray;
implementation
uses Unit2;
{$R *.dfm}
Procedure Rovn_Sg(var SG:Tstringgrid);
var i:byte;
begin
for I := 0 to sg.colcount - 1 do
sg.ColWidths[i]:=round(1.5*sg.RowHeights[0]);
sg.Width:=sg.colcount*sg.ColWidths[0]+sg.colcount*2;
end;
procedure TForm1.Button3Click(Sender: TObject);
var i:integer;
begin
case (sender as Tbutton).tag of
1: for I := 0 to stringgrid1.ColCount-1 do
//stringgrid1.Cells[i,0]:=FloatToStr(Random(20)+random(100)/100-10);
stringgrid1.Cells[i,0]:=InputBox('Введите число','','');
2: for I := 0 to stringgrid2.ColCount-1 do
//stringgrid2.Cells[i,0]:=FloatToStr(Random(20)+random(100)/100-10);
stringgrid2.Cells[i,0]:=InputBox('Введите число','','');
3: for I := 0 to stringgrid3.ColCount-1 do
// stringgrid3.Cells[i,0]:=FloatToStr(Random(20)+random(100)/100-10);
stringgrid3.Cells[i,0]:=InputBox('Введите число','','');
end;
end;
procedure SelectionSort(var A:Tarray);
VAR
i,j, min: integer;
t: double;
begin
for i := 0 to a.col - 1 do begin
min := i;
for j := i + 1 to a.col do
if a.v[min] > a.v[j] then
min := j;
if min<>i then begin
t := a.v[i];
a.v[i] := a.v[min];
a.v[min] := t;
end;
end;
end;
procedure SgToArr(var S:Tstringgrid;var A1:Tarray);
var i:integer;
begin
a1.Col:=s.ColCount-1;
for i := 0 to a1.col do
a1.V[i]:=strToFloat(s.Cells[i,0]);
end;
procedure ArrToSg(var S:Tstringgrid;var A1:Tarray);
var i:integer;
begin
s.ColCount:=a1.Col+1;
for i := 0 to a1.col do
s.Cells[i,0]:=FloatToStr(a1.v[i]);
Rovn_SG(s);
end;
Function InArray( var B1:TArray;R:double):boolean;
var i:integer;
begin
Result:=false;
for I := 0 to B1.Col do
if b1.v[i]=r then
begin
result:=true;
exit;
end;
end;
procedure Find(var A1,B1,C1,D1:TArray);
var i:integer ;
begin
d1.Col:=-1;
for I := 0 to a1.col do
begin
if InArray(B1,A1.v[i]) and InArray(c1,A1.v[i]) and not InArray(d1,a1.v[i]) then
begin
d1.col:=d1.col+1;
d1.V[d.col]:=a1.v[i];
end;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
SgToarr(stringgrid1,A);
SelectionSort(A);
ArrToSg(stringgrid1,A);
//--------------------------//
SgToarr(stringgrid2,B);
SelectionSort(B);
ArrToSg(stringgrid2,B);
//--------------------------//
SgToarr(stringgrid3,C);
SelectionSort(C);
ArrToSg(stringgrid3,C);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
D.Col:=-1;
find(A,B,C,D);
if D.Col=-1 then Showmessage('Одинаковых в 3 массивах нет!!!')
else
begin
SelectionSort(D);
ArrToSg(Stringgrid4,D);
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
var k:integer;
var s:string;
begin
s:=(sender as Tedit).Text;
trystrtoint(s,k);
case(sender as Tedit).Tag of
1:begin
stringgrid1.Colcount:=k;
Rovn_sg(stringgrid1);
end;
2:begin
stringgrid2.Colcount:=k;
Rovn_sg(stringgrid2);
end;
3:begin
stringgrid3.Colcount:=k;
Rovn_sg(stringgrid3);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
Rovn_Sg(stringgrid1);
Rovn_Sg(stringgrid2);
Rovn_Sg(stringgrid3);
Rovn_Sg(stringgrid4);
edit1.Tag:=1;
edit2.Tag:=2;
edit3.Tag:=3;
button1.Tag:=1;
button2.Tag:=2;
button3.Tag:=3;
end;
Надеюсь на вашу помощь!