К какому типу данных относиться key ? Pascal.
Код:
program sharik;
uses graph,crt;
var
x1,x2:integer;
y1,y2:real;
x,xx,xx1,xx2:real;
y,yy:real;
dx:real;
l,b,k,i:integer;
w,h:integer;
mx,my:real;
x0,y0:integer;
st:string;
key:char;
function f(x:real):real;
begin
f:=x*x*x;
begin
clrscr;
i:=0;
InitGraph(i,i,'i:\prg\tp\bgi');
textcolor(5);
gotoxy(22,8);
writeln('Laboratornay rabota 3');
readln;
clrscr;
setfillstyle(1,0);
floodfill(0,0,0);
settextstyle(0,0,1);
setcolor(2);
outtextxy(50,100,'Vvedite levju granitsy(>-5):');
textcolor(green);
gotoxy(8,8);
readln(x1);
setcolor(2);
outtextxy(50,150,'Vvedite pravju granitsy(<5):');
gotoxy(8,11);
readln(x2);
setcolor(4);
outtextxy(50,200,'Vvedite skoroct k:=1-10');
gotoxy(8,14);
readln(k);
k:=100*k;
k:=1000-k;
clrscr;
setfillstyle(1,0);
floodfill(0,0,0);
settextstyle(0,0,1);
dx:=0.01;
l:=10;
b:=420;
h:=440;
w:=600;
y1:=f(x1);
y2:=f(x2);
x:=x1;
while x<=x2 do
begin
y:=f(x);
if y<y1 then y1:=y;
if y<21 then y2:=y;
x:=x+dx;
end;
my:=h/ abs(y2-y1)+50;
mx:=w/ abs(x2-x1)+50;
x0:=300;
y0:=220;
setcolor(3);
line(x0,b+h,x0,b-h);
line(x0-w,y0,x0+w,y0);
setcolor(4);
str(y2:5:1,st);
str(x1:5,st);
str(x2:5,st);
x:=x1;
while x<=x2 do
begin
y:=f(x);
Putpixel(x0+round(x*mx/2),y0-round(y*my/2),4);
x:=x+dx;
end;
x:=x2;
while x<=x2 do
begin
setcolor(0);
circle(x0+round((x-dx)*mx/2),y0-round(f(x-dx)*my/2),8);
setfillstyle(1,0);
floodfill(x0+round((x-dx)*mx/2),y0-round(f(x-dx)*my/2),0);
setcolor(4);
setfillstyle(1,1);
circle(x0+round(x*mx/2),y0-round(f(x)*my/2),8);
floodfill(x0+round(x*mx/2),y0-round(f(x)*my/2),red);
xx:=x1+x/2;
xx2:=x;
delay(k*10);
while xx<=xx2 do
begin
yy:=f(xx);
putpixel(x0+round(xx*mx/2),y0-round(yy*my/2),5);
xx:=xx+dx;
end;
setcolor(3);
line(x0,b+h,x0,b-h);
line(x0-w,y0,x0+w,y0);
setcolor(13);
{str(y2;5;1,st);
outtextxy(x0,5,st);
str(y1:5:st);
outtextxy(x0,y0-9,st);}
str(x1:5,st);
outtextxy(0,y0+2,st);
str(x2:5,st);
outtextxy(w-5,y0+5,st);
setcolor(6);
outtextxy(100,100,'Grafik y=x^3');
{y:=f(x);
putpixel(x0+round(x),y0-round(10),5);}
x:=x+dx;end;readln;
closegraph;
gotoxy(10,10);
write('Povtorit?(y/n)');
readkey;
if key ='y' then goto 1;
end.
|