Advertisement
ALTracer

lab1v8n2

Jun 20th, 2015
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.91 KB | None | 0 0
  1. program lab1v8n2;
  2. var
  3.   A:array[1..1000]of Integer;
  4.   D:array of Real;
  5.   N:Integer;
  6.  
  7. procedure ProcessData;
  8. var i,num,a_p,a_n:Word;
  9.     med:Real;
  10. begin
  11.      med:=0;
  12.      a_p:=0;
  13.      a_n:=0;
  14.      for i:=1 to N do
  15.        if a[i]>0
  16.        then begin
  17.          med:=med+a[i];
  18.          Inc(a_p);
  19.        end
  20.        else Inc(a_n);
  21.      if a_p>0 then med:=med/a_p;
  22.      SetLength(D,N+1);
  23.      for i:=1 to N do
  24.        if i mod 2=0
  25.          then D[i]:=a_n
  26.          else D[i]:=med;
  27. end;
  28.  
  29. procedure ImportData;
  30. var j:Integer;
  31. begin
  32.      WriteLn('Input the length, then the elements of an array');
  33.      ReadLn(N);
  34.      for j:=1 to N do Read(a[j]);
  35. end;
  36. procedure ExportData;
  37. var j:Integer;
  38. begin
  39.      WriteLn;
  40.      for j:=1 to N do
  41.        if j mod 2=0
  42.         then Write(d[j]:0:0,' ')
  43.         else Write(d[j]:0:4,' ')
  44. end;
  45.  
  46. //main
  47. begin
  48.      ImportData;
  49.      ProcessData;
  50.      ExportData;
  51. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement