Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.03 KB | None | 0 0
  1. program student_zaliczenie;
  2. {$mode objfpc}{$H+}
  3. uses SysUtils;
  4. type tab = array[0..9] of Double; //zadanie pierwsze
  5. var i: integer;
  6. var t:tab;
  7.  
  8. Function srednia(t: tab): Real;
  9. var suma: Double;
  10. Begin
  11.   suma:=0;
  12.   for i:=0 to 9 do
  13.   begin
  14.   suma:=suma+t[i];
  15.   end;
  16.   srednia:=suma/10;
  17. end;
  18.  
  19. function sredniazmniejszychodzera(t: Tab): double;
  20. var sumuj: double; liczuj: integer;
  21. begin
  22.   sumuj:=0;
  23.   liczuj:=0;
  24.  for i:=0 to 9 do
  25. if t[i]<0 then
  26. begin
  27. sumuj:=sumuj+t[i];
  28. liczuj:=liczuj+1;
  29. end;
  30. if liczuj=0 then result:=0
  31. else result:=sumuj/liczuj;
  32. end;
  33.  
  34.  
  35.  
  36. Begin
  37. Writeln ('Wczytaj dane do tablicy');
  38. Writeln;
  39. For i:=0 to 9 do
  40.     Begin
  41.         Write('Podaj ',i,' element: '); ReadLn(t[i]);
  42.     End;
  43. WriteLn;
  44. WriteLn('Oto zawartosc twojej tablicy');
  45. WriteLn;
  46. For i:=0 to 9 do
  47. Begin
  48. Write (i, ': ', t[i]:0:2, '    ');
  49. end;
  50. WriteLn;
  51. Write('Srednia z podanych liczb wynosi: ');
  52. Writeln(srednia(t):4:2);
  53. WriteLn;
  54. Writeln('srednia liczb ujmenych wynosi ',sredniazmniejszychodzera(t):4:2);
  55. readln;
  56. end.
  57.  
  58. end.
  59. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement