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
Ipocicloide - MODELLO.PAS

MODELLO.PAS

Caricato da: Poggi Marco
Scarica il programma completo

  1. unit modello;
  2.  
  3. interface
  4. uses crt, dos;
  5.  
  6.  function getchar:char;
  7.  procedure pausa(fr:string; x,y:word);
  8.  procedure linea(s:char);
  9.  function exit_not(fr:string; p:char):boolean;
  10.  function IntDomanda(f:string; l1,l2:longint):longint;
  11.  function RealDomanda(f:string; l1,l2:double):double;
  12.  procedure CentraFrase(f:string; lin:word);
  13.  function tempo:double;
  14.  function numero(n:double; cifre,dec:byte):string;
  15.  function destra(fr,r:string; fine:word):string;
  16.  
  17. implementation
  18.  
  19. function getchar:char;
  20. begin
  21.  if keypressed then getchar:=readkey
  22.  else getchar:=chr(0);
  23. end;
  24.  
  25. procedure pausa(fr:string; x,y:word);
  26. var i,fine:byte;
  27. begin
  28.  textcolor(7);
  29.  gotoxy(x,y);
  30.  fine:=ord(fr[0]);
  31.  for i:=1 to fine do write(fr[i]);
  32.  write(' '+readkey);
  33. end;
  34.  
  35. procedure linea(s:char);
  36. var i:byte;
  37.  begin
  38.   writeln;
  39.   for i:=0 to 79 do  write(s);
  40. end;
  41.  
  42. function exit_not(fr:string; p:char):boolean;
  43. var r:char;
  44.  begin
  45.   write(fr);
  46.   r:=upcase(getchar);
  47.   p:=upcase(p);
  48.   writeln(r);
  49.   if r=p then exit_not:=true else exit_not:=false;
  50.   linea('-');
  51. end;
  52.  
  53. function IntDomanda(f:string; l1,l2:longint):longint;
  54. begin
  55.  IntDomanda:=trunc(RealDomanda(f, l1, l2));
  56. end;
  57.  
  58. function RealDomanda(f:string; l1,l2:double):double;
  59. var t:double;
  60.     num:string;
  61.     errore:integer;
  62.     ch:boolean;
  63. begin
  64.  repeat
  65.   write(f+' ');
  66.   readln(num);
  67.   val(num, t, errore);
  68.   if errore=0 then
  69.   begin
  70.    ch:=((t>=l1) and (t<=l2));
  71.    if not ch then
  72.    begin
  73.     writeln('Limiti ammessi { ',l1:8:3,' -> ',l2:8:3,' }');
  74.    end;
  75.   end
  76.   else
  77.   begin
  78.    writeln('Sono ammessi solo numeri!');
  79.    ch:=false;
  80.   end;
  81.  until ch;
  82.  RealDomanda:=t;
  83. end;
  84.  
  85. procedure CentraFrase(f:string; lin:word);
  86. var l,x0:word;
  87. begin
  88.  l:=length(f);
  89.  x0:=(80-l) div 2;
  90.  gotoxy(x0,lin);
  91.  writeln(f);
  92. end;
  93.  
  94. function tempo:double;
  95. var h,m,s,cs:word;
  96. begin
  97.  GetTime(h, m, s, cs);
  98.  tempo:=3600.0 * (h+0.0) + 60.0*m + s + 0.01*cs;
  99. end;
  100.  
  101. function numero(n:double; cifre,dec:byte):string;
  102. var s:string;
  103. begin
  104.  str(n:cifre:dec, s);
  105.  numero:=s;
  106. end;
  107.  
  108. function destra(fr,r:string; fine:word):string;
  109. var i:word;
  110. begin
  111.  while length(fr)<fine do
  112.  begin
  113.   fr:=fr+r;
  114.  end;
  115.  destra:=fr;
  116. end;
  117.  
  118. begin
  119.  
  120. end.