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
| program lab3;
uses Crt;
var x, s, h, minlim, maxlim, funcabspog:real;
prssedkey:char;
enteredlims, enteredstep, hasresult:boolean;
curitem: integer;
const menu: array[1..5] of string = ('Predely', 'Shag', 'Result', 'Pogreshnost``', 'Exit');
procedure writemenu();
var item:integer;
begin
for item:= 1 to length(menu) do begin
if item = curitem then TextBackground(Blue)
else TextBackground(Black);
writeln(item,'.',menu[item]);
end;
TextBackground(Black);
end;
function f(x:real):real;
begin
f:=x*x*x+(-2)*x*x+(-2)*x+(10);
end;
function fp(x:real):real;
begin
fp:=;
end;
begin
enteredstep:=false;
enteredlims:=false;
hasresult:=false;
curitem:=1;
while true do begin
clrscr();
writemenu();
while true do begin
prssedkey:=ReadKey();
if prssedkey = char(13) then break;
if prssedkey <> char(0) then continue;
prssedkey:= ReadKey();
case prssedkey of
char(72): curitem:=curitem-1;
char(80): curitem:=curitem+1;
else continue;
end;
if curitem>length(menu) then curitem:=1
else if curitem<1 then curitem:=length(menu);
clrscr();
writemenu();
end;
writeln();
case curitem of
1: begin
repeat begin
Write('min: '); readln(minlim);
if minlim<=-2.3888 then begin
writeln('nizhniy predel dolzhen byt` >-2.3888');
continue;
end;
Write('max: '); readln(maxlim);
if maxlim<=minlim then
writeln('nizhniy predel dolzhen byt` men`she verhnego');
end until (maxlim>minlim) and (minlim>-2.3888);
enteredlims:= true;
hasresult:=false;
end;
2: begin
repeat begin
Write('shag: '); readln(h);
if h<=0 then writeln('shag dolzhen byt` >0.');
end until h>0;
enteredstep:= true;
hasresult:=false;
end;
3: begin
if (enteredstep = false) or (enteredlims = false) then writeln('vvedeny ne vse dannye')
else begin
s:=0;
x:= minlim;
repeat begin
x:=x+h;
s:=s+f(x)*h;
end until x>maxlim;
writeln('s=', s:0:4);
hasresult:=true;
end;
end;
4: begin
if hasresult = false then writeln('snachala nado poschitat` plochshad`')
else begin
funcabspog:=abs(fp(maxlim) - fp(minlim) - s);
writeln('abs pog=',funcabspog:0:4);
writeln('otn pog=',(s/funcabspog*100):0:4,'%');
end;
end;
5: exit;
end;
ReadLn();
end;
ReadLn();
end. |