Skip to content

Instantly share code, notes, and snippets.

@RobertMatkulcik
Last active July 31, 2016 11:46
Show Gist options
  • Save RobertMatkulcik/15352eb697529516078712d4805c0316 to your computer and use it in GitHub Desktop.
Save RobertMatkulcik/15352eb697529516078712d4805c0316 to your computer and use it in GitHub Desktop.
Pascal - majherova
{
test.pas
Copyright 2016 HlbinaMyslenia10 <hlbinamyslenia10@linux-pmeg.site>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
ZADANIE:
* bude pocitat sucet cisel textoveho suboru "cisla.txt", ktorý si vy vytorite
* zisti, kolko cisel sa nachadza v subore "cisla.txt"
* vypocita priemer cisel, ktore sa nachadzaju v subore "cisla.txt"
* vypise na obrazovku sucet, pocet a priemer cisel
}
program homework;
uses crt;
var
F: Text;
A: array[0..9999999] of Integer;
I, J, M: Integer;
priemer: real;
BEGIN
M:= 0;
I :=-1;
assign(F, '/home/hlbinamyslenia/MEGA/pascal/Homework_pascal/cisla.txt');
reset(F);
while not eof(F) do
begin
inc(I);
readln(f, A[I]);
end;
Close(F);
for J:= 0 to (I) do
begin
write(A[J], ' ');
M:= A[J] + M;
end;
writeln();
writeln('Pocet cisel je : ', I);
writeln('Sucet je: ', M);
priemer:= M / I;
writeln('Priemer cisel je: ', priemer:3:3);
readln;
END.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment