Контрольная работа по "Программированию"
Автор: venyadronest • Сентябрь 25, 2023 • Контрольная работа • 546 Слов (3 Страниц) • 77 Просмотры
Отчет по работе
Вариант – 3
Код программы:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, jpeg, ExtCtrls, Grids;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N4: TMenuItem;
PopupMenu1: TPopupMenu;
yx2: TMenuItem;
N5: TMenuItem;
max2: TMenuItem;
min2: TMenuItem;
sum4: TMenuItem;
sum5: TMenuItem;
sum6: TMenuItem;
mult4: TMenuItem;
mult5: TMenuItem;
mult6: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
Raschet: TButton;
N1: TMenuItem;
N2: TMenuItem;
img1: TImage;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
krit1: TButton;
cbb1: TComboBox;
strngrd1: TStringGrid;
lst1: TListBox;
lst2: TListBox;
Label1: TLabel;
procedure N4Click(Sender: TObject);
procedure RaschetClick(Sender: TObject);
procedure krit1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.N4Click(Sender: TObject);
begin
if MessageBox(0, PChar('Вы точно хотите выйти?'), PChar('Выход'),
MB_YESNO+MB_ICONQUESTION)=idYes then Application.Terminate;
end;
function y(x,a:integer):double;
begin
Result:=0;
Case A of
1:Result:=A-Sin(X) / Cos(X);
2:Result:=sqrt(exp(x*ln(A)));
-1:Result:=cos(x-A);
end;
end;
var
arr:Array[0..10] of Double;
procedure TForm1.RaschetClick(Sender: TObject);
var
x:integer;
i:integer;
begin
lst1.Clear;
lst2.Clear;
x := 0;
if ((StrToInt(cbb1.Text) <> -1) and (StrToInt(cbb1.Text) <> 1) and (StrToInt(cbb1.Text) <> 2))
then begin
ShowMessage('Введите другое значение');
lst1.Clear;
lst2.Clear;
strngrd1.CleanupInstance;
end;
while(x <= 10)do begin
arr[x] := y(x,StrToInt(cbb1.Text));
x := x + 1;
end;
strngrd1.Cells[0,0] := 'x';
strngrd1.Cells[0,1] := 'y';
for i:=0 to 10 do begin
strngrd1.Cells[i + 1,0] := IntToStr(i);
strngrd1.Cells[i+1,1] := FloatToStr(arr[i]);
if arr[i] < 0
then lst2.Items.Add(FloatToStr(arr[i]))
else lst1.Items.Add(FloatToStr(arr[i]));
end;
end;
function maxY():double;
var
i:Integer;
max:Double;
begin
max := arr[0];
for i:=1 to 10 do begin
if arr[i] > max
then max := arr[i];
end;
Result := max;
end;
function minY():double;
var
i:Integer;
min:Double;
begin
min := arr[0];
for i:=1 to 10 do begin
if arr[i] < min
then min := arr[i];
end;
Result := min;
end;
function sumY():double;
var
i:Integer;
sum:Double;
begin
sum := 0;
for i:=1 to 10 do begin
sum := sum + arr[i];
end;
Result := sum;
end;
function mulY():double;
var
i:Integer;
mul:Double;
begin
...