program menu; uses crt, graph; const m: array [1..5] of string[20]=('O programme','Vvod ishodnih dannih', 'Raschet', 'Grafik', 'Vihod'); var e: char; d,f: integer; a,b:real; s:real; r:boolean; gd, gm:integer; {--------------------} procedure vibor(c:integer); var i:word; begin clrscr; for i:=1 to 5 do begin if i=c then textcolor (11) else textcolor (15); gotoxy (30,9+i); write (m[i]); end; end; {--------------------} procedure o_programme; begin end; {--------------------------} function p(str:string):boolean; var i:integer; begin p:=true; for i:=1 to length(str) do if ((ord(str[i])<45) or (ord(str[i])>57)) or (ord(str[i])=47) then begin p:=false; exit; end; end; {--------------------------} procedure vvod_predelov(var a, b:real); var str:string; i:integer; begin clrscr; textcolor(15); writeLn('Vvedite nizhniy predel i nagmite :'); str:=''; while str =''do begin readln(str); if p(str) then val(str, a, i) else begin str := ''; writeLn('Predeli mogut bit'' tol''ko ciframi'); end; end; writeLn; writeLn('Vvedite verhniy predel i nagmite :'); str:=''; while str='' do begin readln(str); if p(str) then val(str, b, i) else begin str:=''; writeLn('Predeli mogut bit'' tol''ko ciframi'); end; if b<=a then begin str:=''; writeLn('Verhniy predel mozhet bit'' tol''ko bol''she nizhnego'); end; end; writeLn; r:=true; textcolor(31); writeLn('Nazhmite lubuyu klavishu'); readkey; end; {--------------------------} procedure raschet (a, b:real;var S:real); begin clrscr; writeln ('Znachenie dannogo integrala ravno:'); writeln; writeln(' b '); writeln(' -- '); writeln(' | (5-2x)dX = (5b-(2(b^2)/2))-(5a-(2(a^2)/2)) = (5b-(b^2))-(5a-(a^2))'); writeln('--'); writeln('a '); writeln; if r=false then begin writeln('Dlya rascheta integrala vvedite ''a'' i ''b''.'); writeln; writeln('Nazhmite lubuyu klavishu'); readkey; exit; end; S:=((5*b-b*b)-(5*a-a*a)); writeln ('Integral=',s:6:2); writeln; textcolor (31); writeln('Nazhmite lubuyu klavishu'); readkey; end; {--------------------------} Procedure grafik; Var x, y,xx, yy, Y2, Y1, Y4, Y3, St, y0, z : Real; i:integer; t:string; begin clrscr; if r=false then begin writeLn('Znachenia predelov ne bili vvedeni. Vvedite ''a'' i ''b''.'); writeLn; textcolor(3); writeLn('Nagmite lubuyu klavishu'); readKey; exit; end; InitGraph(gd, gm, ''); setfillstyle(solidfill,15); bar (65,90,575,420); setcolor (3); for i:=1 to 11 do line (65,60+30*i,575,60+30*i); for i:=1 to 18 do line (35+30*i,90,35+30*i,420); y2:=-1000000; y1:= 1000000; x:=80; while (x<=560) do begin xx:=(x-80)/505*(b-a)+a; yy:=5-2*xx; if (y2yy) then y1:=yy; x:=x+1; end; st:=(y2-y1)/10; y4:=y2; y3:=y1; if (y1>0) and (y2>0) Then begin y1:=-st; y2:=y2+st; end else if (y1<0) and (y2<0) then begin y2:=st; y1:=y1-st; end else begin y1:=y1-st; y2:=y2+st; end; setcolor (9); y0:=-y1/(y2-y1)*320+80; line(80,505-round(y0),560,505-round(y0)); xx:=a; yy:=(5-2*xx); y:=(yy-y1)/(y2-y1)*320+80; line(80,505-round(y),80,505-round(y0)); xx:=(560-80)/505*(b-a)+a; yy:=(5-2*xx); y:=(yy-y1)/(y2-y1)*320+80; line(560,505-round(y),560,505-round(y0)); z:=y0; x:=80; while (x<=560) do begin xx:=(x-80)/505*(b-a)+a; yy:=(5-2*xx); y:=(yy-y1)/(y2-y1)*320+80; line(round(x)-1,505-round(z),round(x),505-round(y)); z:=y; x:=x+1; end; setcolor(11); outtextxy(250, 40, 'Integral = '); S:=5*b-2/2*b*b-5*a+2/2*a*a; str(s:6:2, t); outtextxy(340, 40, t); setcolor(4); x:=-a/(b-a)*480+80; line(round(x), 120, round(x), 440); y:=-y1/(y2-y1)*320+120; line(80,520-round(y),560,520-round(y)); setcolor(11); str(a:2:2,t); outtextxy(60,430,'a='+t); str(b:2:2,t); outtextxy(530,430,'b='+t); str(y4:2:2,t); outtextxy(280,60,'ymax='+t); str(y3:2:2,t); outtextxy(280,430,'ymin='+t); outtextxy(285,20,'y=5-2x'); setcolor(10); outtextxy(235,455,'Nagmite lubuyu klavishu'); readkey; closegraph; end; {---------------------------} begin clrscr; d:=1; f:=1; vibor(d); repeat e:=readkey; if e=chr(0) then begin e:=readkey; case e of chr(72): if d=1 then d:=5 else d:=d-1; chr(80): if d=5 then d:=1 else d:=d+1; else write ('nagata ne ta klavisha'); end; end else begin case e of chr(27) : f:=0; chr(13) : case d of 1: o_programme; 2: vvod_predelov(a, b); 3: raschet(a, b,s); 4: grafik; 5: f:=0; end; else begin gotoxy(15,20); write('Ne ta klavisha,nagmite '); readln; end; end; end; vibor(d); until f=0; end.