Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program student_zaliczenie;
- {$mode objfpc}{$H+}
- uses SysUtils;
- type tab = array[0..9] of Double; //zadanie pierwsze
- var i: integer;
- var t:tab;
- Function srednia(t: tab): Real;
- var suma: Double;
- Begin
- suma:=0;
- for i:=0 to 9 do
- begin
- suma:=suma+t[i];
- end;
- srednia:=suma/10;
- end;
- function sredniazmniejszychodzera(t: Tab): double;
- var sumuj: double; liczuj: integer;
- begin
- sumuj:=0;
- liczuj:=0;
- for i:=0 to 9 do
- if t[i]<0 then
- begin
- sumuj:=sumuj+t[i];
- liczuj:=liczuj+1;
- end;
- if liczuj=0 then result:=0
- else result:=sumuj/liczuj;
- end;
- Begin
- Writeln ('Wczytaj dane do tablicy');
- Writeln;
- For i:=0 to 9 do
- Begin
- Write('Podaj ',i,' element: '); ReadLn(t[i]);
- End;
- WriteLn;
- WriteLn('Oto zawartosc twojej tablicy');
- WriteLn;
- For i:=0 to 9 do
- Begin
- Write (i, ': ', t[i]:0:2, ' ');
- end;
- WriteLn;
- Write('Srednia z podanych liczb wynosi: ');
- Writeln(srednia(t):4:2);
- WriteLn;
- Writeln('srednia liczb ujmenych wynosi ',sredniazmniejszychodzera(t):4:2);
- readln;
- end.
- end.
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement