RobqFakulcik
4/30/2016 - 11:35 AM

Pascal - majherova

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.