unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Math;
type
TForm6 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
StringGrid1: TStringGrid;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
Y:array of array of real;
C:array of array of real;
A:array of array of real;
B:array of array of real;
n:integer;
m:integer;
k:integer;
l:integer;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm6.Button1Click(Sender: TObject);
begin
Form1.Show;
Form6.Close;
end;
procedure TForm6.Button2Click(Sender: TObject);
var i,j:integer;
begin
n:=strtoint(edit1.Text);
m:=strtoint(edit2.Text);
setlength(Y,n,m);
stringgrid1.RowCount:=n;
stringgrid1.ColCount:=m;
for i:=0 to n-1 do
for j:=0 to m-1 do
begin
Y[i,j]:=random(50--50+1)-50;
stringgrid1.Cells[j,i]:=FormatFloat('0.00',Y[i,j]);
end;
end;
procedure TForm6.Button3Click(Sender: TObject);
var i,j,t:integer;
tmp:real;
begin
m:=stringgrid1.ColCount;
k:=strtoint(edit3.text)-1;
l:=strtoint(edit4.text)-1;
if (k=-1) then
begin
showmessage('Перестановка столбцов невозможно, проверьте введеные данные!');
exit;
end;
if (l=-1) then
begin
showmessage('Перестановка столбцов невозможно, проверьте введеные данные!');
exit;
end;
if (k>m-1) then
begin
showmessage('Перестановка столбцов невозможно, проверьте введеные данные!');
exit;
end;
if (l>m-1) then
begin
showmessage('Перестановка столбцов невозможно, проверьте введеные данные!');
exit;
end;
for i:=0 to n-1 do
begin
tmp:=Y[i,k];
Y[i,k]:=Y[i,l];
Y[i,l]:=tmp;
end;
for t:=0 to n-1 do
for j:=0 to m-1 do
stringgrid1.Cells[j,t]:=FormatFloat('0.00',Y[t,j]);
end;
procedure TForm6.Button4Click(Sender: TObject);
var i,j:integer;
begin
n:=7;
m:=11;
setlength(C,n,m);
stringgrid1.RowCount:=n;
stringgrid1.ColCount:=m;
for i:=0 to n-1 do
for j:=0 to m-1 do
begin
C[i,j]:=cos(14*j+1);
stringgrid1.Cells[j,i]:=FormatFloat('0.00',C[i,j]);
end;
end;
procedure TForm6.Button5Click(Sender: TObject);
var i,j,t:integer;
tmp:real;
begin
m:=stringgrid1.ColCount;
k:=0;
l:=10;
for i:=0 to n-1 do
begin
tmp:=C[i,k];
C[i,k]:=C[i,l];
C[i,l]:=tmp;
end;
for t:=0 to n-1 do
for j:=0 to m-1 do
stringgrid1.Cells[j,t]:=FormatFloat('0.00',C[t,j]);
end;
procedure TForm6.Button6Click(Sender: TObject);
var i,j:integer;
begin
n:=12;
m:=9;
setlength(A,n,m);
stringgrid1.RowCount:=n;
stringgrid1.ColCount:=m;
for i:=0 to n-1 do
for j:=0 to m-1 do
begin
A[i,j]:=sin(j)/cos(j)+exp(cos(i));;
stringgrid1.Cells[j,i]:=FormatFloat('0.00',A[i,j]);
end;
end;
procedure TForm6.Button7Click(Sender: TObject);
var i,j,t:integer;
tmp:real;
begin
m:=stringgrid1.ColCount;
k:=0;
l:=8;
for i:=0 to n-1 do
begin
tmp:=A[i,k];
A[i,k]:=A[i,l];
A[i,l]:=tmp;
end;
for t:=0 to n-1 do
for j:=0 to m-1 do
stringgrid1.Cells[j,t]:=FormatFloat('0.00',A[t,j]);
end;
procedure TForm6.Button8Click(Sender: TObject);
var i,j:integer;
begin
n:=8;
m:=15;
setlength(B,n,m);
stringgrid1.RowCount:=n;
stringgrid1.ColCount:=m;
for i:=0 to n-1 do
for j:=0 to m-1 do
begin
B[i,j]:=sin(3.2*j+4.2)+power(exp(1),tan(i));
stringgrid1.Cells[j,i]:=FormatFloat('0.00',B[i,j]);
end;
end;
procedure TForm6.Button9Click(Sender: TObject);
var i,j,t:integer;
tmp:real;
begin
m:=stringgrid1.ColCount;
k:=2;
l:=4;
for i:=0 to n-1 do
begin
tmp:=B[i,k];
B[i,k]:=B[i,l];
B[i,l]:=tmp;
end;
for t:=0 to n-1 do
for j:=0 to m-1 do
stringgrid1.Cells[j,t]:=FormatFloat('0.00',B[t,j]);
end;
procedure TForm6.Button10Click(Sender: TObject);
var
i,j:integer;
begin
for i:=0 to n-1 do
for j:=0 to m-1 do
stringgrid1.Cells[i,j]:=FormatFloat(' ',0);
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
end;
end.