-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnit1.~pas
143 lines (115 loc) · 3.21 KB
/
Unit1.~pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
UpDown1: TUpDown;
RadioGroup1: TRadioGroup;
CheckBox1: TCheckBox;
StringGrid1: TStringGrid;
Label2: TLabel;
Label3: TLabel;
Edit2: TEdit;
RadioGroup2: TRadioGroup;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit2Exit(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
// ïåðâàÿ ñòðîêà òàáëèöû
verh : array [0..3] of string[20] = (' d \ F', 'F1(a,b,c,d)', 'F2(a,b,c,d)', 'F3(a,b,c,d)');
// çíà÷åíèÿ â ïåðâîì ñòîëáöå
perStr : array [0..6] of string[20] = ('Monday', 'Tuesday', 'Weednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
type
per = (Monday,Tuesday,Weednesday,Thursday,Friday,Saturday,Sunday);
//ñþäà ìîæíî íàïèñàòü ñâîè ôóíêöèè f1, f2, f3
procedure TForm1.Button1Click(Sender: TObject);
var
b,i: shortint;
c: single;
a: boolean;
d,d1,d2: per;
Res1: boolean;
Res2: integer;
Res3: single;
begin
a:=CheckBox1.Checked;
b:=UpDown1.Position;
c:=StrToFloat(Edit2.Text);
d1:=per(RadioGroup1.ItemIndex);
d2:=per(RadioGroup2.ItemIndex);
// ïîãîòîâêà òàáëèöû
// êîëè÷åñâî ñòðîê
StringGrid1.RowCount:=Ord(d2)-Ord(d1)+2;
// çàãîëîâîê
for i:=0 to 3 do
StringGrid1.Cells[i,0]:=verh[i];
// çíà÷åíèÿ d â òàáëèöå
for i:=Ord(d1) to Ord(d2) do
StringGrid1.Cells[0,i-Ord(d1)+1]:=perStr[i];
for d:=d1 to d2 do
begin
Res1:=(not A) or (not(odd(b))and(d=Friday));
Res2:=sqr(b-ord(d));
Res3:=(8*cos(((Ord(d))*pi)/3))-((ln(10+((abs(c))/2)))/ln(2));
if Res1 then
StringGrid1.Cells[1, Ord(d)-Ord(d1)+1]:='True'
else
StringGrid1.Cells[1, Ord(d)-Ord(d1)+1]:='False';
StringGrid1.Cells[2, Ord(d)-Ord(d1)+1]:=IntToStr(Res2);
StringGrid1.Cells[3, Ord(d)-Ord(d1)+1]:=Format('%8.4f',[Res3]);
// èëè StringGrid1.Cells[3, Ord(d)-Ord(d1)+1]:=FloatToStrF(Res3, ffFixed, 8, 4);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Edit2Exit(Sender: TObject);
var prob_c: single;
begin
try // ïîïûòàåìñÿ
prob_c:=StrToFloat(Edit2.Text);
if not (abs(prob_c)<20) then
begin
ShowMessage('Ñ äîëæíî ëåæàòü íà îòðåçêå (-20, 20)');
Edit2.Text:='3';
end;
except // åñëè ïðè ïðåîáðàçîâàíèè StrToFloat îøèáêà
ShowMessage('Ñ - íå ÷èñëî èëè íóæíà . âìåñòî ,');
Edit2.Text:='3';
end;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex > RadioGroup2.ItemIndex then
begin
ShowMessage('D1 äîëæíî áûòü ìåíüøå èëè ðàâíî D2');
RadioGroup1.ItemIndex := RadioGroup2.ItemIndex;
end;
end;
procedure TForm1.RadioGroup2Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex > RadioGroup2.ItemIndex then
begin
ShowMessage('D2 äîëæíî áûòü áîëüøå èëè ðàâíî D1');
RadioGroup2.ItemIndex := RadioGroup1.ItemIndex;
end;
end;
end.