Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Lanci - LANCI.PAS

LANCI.PAS

Caricato da: Poggi Marco
Scarica il programma completo

  1. Program Modello2_00;
  2. type str=string[80];
  3. var v,g:real;
  4.  
  5. procedure assi(x,y:integer);
  6. begin
  7.  draw(0,0,0,y,1);
  8.  draw(0,y,x,y,1);
  9. end;
  10.  
  11. procedure inizio;
  12. var x,y:integer;
  13. begin
  14.  hires;
  15.  hirescolor(1);
  16.  x:=639;
  17.  y:=199;
  18.  assi(x,y);
  19. end;
  20.  
  21. procedure pausa(f:str; ri,co:integer);
  22. var i,fine:byte;
  23. begin
  24.  gotoxy(ri,co);
  25.  write(f);
  26.  while not keypressed do ;
  27.  fine:=ord(f[0]);
  28.  gotoxy(ri,co);
  29.  for i:=1 to fine do  write(' ');
  30. end;
  31.  
  32. procedure punto(cx,cy:real);
  33. var px,py:integer;
  34. begin
  35.  px:=round(cx);
  36.  py:=round(0-cy);
  37.  if (px>=0) and (px<640) then
  38.  begin
  39.   if (py>=0) and (py<200) then plot(px,py,1);
  40.  end;
  41. end;
  42.  
  43. procedure cerchio(xc,yc,ra:real);
  44. var i,fine:integer;
  45.     x,y,al,g:real;
  46. begin
  47.  fine:=400;
  48.  g:=(2*pi)/fine;
  49.  for i:=0 to fine do
  50.  begin
  51.   al:=i*g;
  52.   x:=xc+2*ra*cos(al);
  53.   y:=yc+ra*sin(al);
  54.   punto(x,y);
  55.  end;
  56. end;
  57.  
  58. procedure lancio(ve,a:real);
  59. var i,fine,re:integer;
  60.     t,x,y,kt,tf:real;
  61. begin
  62.  fine:=2000;
  63.  tf:=sqrt(400/abs(a));
  64.  kt:=tf/fine;
  65.  t:=0;
  66.  i:=0;
  67.  while t<=tf do
  68.  begin
  69.   x:=t*ve;
  70.   y:=0.5*a*t*t;
  71.   punto(x,y);
  72.   re:=i mod (fine div 10);
  73.   if re=0 then cerchio(x,y,10);
  74.   t:=t+kt;
  75.   i:=i+1;
  76.  end; {fine ciclo while}
  77. end;
  78.  
  79. procedure domanda(var ve:real; min,max:real);
  80. var inserito:str;
  81.     errore:integer;
  82. begin
  83.  writeln('Velocit… in km/h');
  84.  repeat
  85.   write('v ( tra ',min:3:0,' e ',max:4:0,' ) ');
  86.   readln(inserito);
  87.   val(inserito, ve, errore);
  88.  until ((ve>min) and (ve<max)) and (errore=0);
  89.  ve:=ve/3.6;
  90. end;
  91.  
  92. procedure mostra(ve,g:real; co:integer);
  93. var t,s:real;
  94. begin
  95.  t:=sqrt(400/abs(g));
  96.  s:=t*ve;
  97.  gotoxy(co,1);
  98.  write('Tempo:    ',t:6:4,' s');
  99.  gotoxy(co,2);
  100.  write('Distanza: ',s:6:2,' m');
  101. end;
  102.  
  103. begin
  104.  g:=0.0-9.80665;
  105.  domanda(v,0,370);
  106.  inizio;
  107.  lancio(v,g);
  108.  pausa('Premi un tasto per continuare... ',30,1);
  109.  mostra(v,g,30);
  110.  pausa('Pausa... ',30,20);
  111. end.