Skip to content

Instantly share code, notes, and snippets.

@vertrigo
Created November 21, 2012 16:00
Show Gist options
  • Select an option

  • Save vertrigo/4125661 to your computer and use it in GitHub Desktop.

Select an option

Save vertrigo/4125661 to your computer and use it in GitHub Desktop.
Program lab8a;
Uses crt;
Var f: file of integer; x,s,k: integer; sr:real; c:char;
Begin
clrscr;assign (f,'lab12.dat');rewrite (f);
writeln ('Введите целые числа. Признак конца ввода - 0');
repeat
read (x) ;x := abs(x);write(f,x)
until x = 0;
reset(f);
writeln('Содержимое файла:');
s:=0; k:=0;
while not eof(f) do
begin
read (f,x);write (x:4);
if filepos(f) mod 2 = 0 then begin
s:=s+x;
k:=k+1;
end;
end;
sr:=s/k;
writeln('Среднее арифм. значение с элементов с четными номерами: ',sr:3:1);
close (f); writeln;
c:= readkey
End.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment