|
Program Modello2_00;
type str=string[80];
var v,g:real;
procedure assi(x,y:integer);
begin
draw(0,0,0,y,1);
draw(0,y,x,y,1);
end;
procedure inizio;
var x,y:integer;
begin
hires;
hirescolor(1);
x:=639;
y:=199;
assi(x,y);
end;
procedure pausa(f:str; ri,co:integer);
var i,fine:byte;
begin
gotoxy(ri,co);
write(f);
while not keypressed do ;
fine:=ord(f[0]);
gotoxy(ri,co);
for i:=1 to fine do write(' ');
end;
procedure punto(cx,cy:real);
var px,py:integer;
begin
px:=round(cx);
py:=round(0-cy);
if (px>=0) and (px<640) then
begin
if (py>=0) and (py<200) then plot(px,py,1);
end;
end;
procedure cerchio(xc,yc,ra:real);
var i,fine:integer;
x,y,al,g:real;
begin
fine:=400;
g:=(2*pi)/fine;
for i:=0 to fine do
begin
al:=i*g;
x:=xc+2*ra*cos(al);
y:=yc+ra*sin(al);
punto(x,y);
end;
end;
procedure lancio(ve,a:real);
var i,fine,re:integer;
t,x,y,kt,tf:real;
begin
fine:=2000;
tf:=sqrt(400/abs(a));
kt:=tf/fine;
t:=0;
i:=0;
while t<=tf do
begin
x:=t*ve;
y:=0.5*a*t*t;
punto(x,y);
re:=i mod (fine div 10);
if re=0 then cerchio(x,y,10);
t:=t+kt;
i:=i+1;
end; {fine ciclo while}
end;
procedure domanda(var ve:real; min,max:real);
var inserito:str;
errore:integer;
begin
writeln('Velocit… in km/h');
repeat
write('v ( tra ',min:3:0,' e ',max:4:0,' ) ');
readln(inserito);
val(inserito, ve, errore);
until ((ve>min) and (ve<max)) and (errore=0);
ve:=ve/3.6;
end;
procedure mostra(ve,g:real; co:integer);
var t,s:real;
begin
t:=sqrt(400/abs(g));
s:=t*ve;
gotoxy(co,1);
write('Tempo: ',t:6:4,' s');
gotoxy(co,2);
write('Distanza: ',s:6:2,' m');
end;
begin
g:=0.0-9.80665;
domanda(v,0,370);
inizio;
lancio(v,g);
pausa('Premi un tasto per continuare... ',30,1);
mostra(v,g,30);
pausa('Pausa... ',30,20);
end.
|
|