Created
November 21, 2012 16:00
-
-
Save vertrigo/4125661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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