Дано файл який містить цілі числа . Визначити середнє арифметичне найменшого і найбільшого елементів в Pascal
Надо написать полную програму !!!ПЛИЗ!!!
Надо написать полную програму !!!ПЛИЗ!!!
Программа для файла содержащего не более 50 целых чисел:
uses crt;
const n=50;
type Data=array[1..n] of integer;
var f,g:Text;
name:string;
IO,Count,Max,Min,buf:integer;
srednee:real;
Mas:Data;
begin
repeat
ClrScr;
write('File: ');
readln(name);
Assign(f,name);
{$I-}
Reset(f);
{$I+}
IO:=IOResult;
if IO<>0 then
begin
write('I/O error! Press any key to repeat...');
readkey;
end;
until (IO=0) and (name<>'');
Count:=0;
Max:=-32768;
Min:=32767;
srednee:=0;
while (not eof(f)) and (Count
if buf>=Max then Max:=buf;
if buf<=Min then Min:=buf;
srednee:=srednee+buf;
Mas[Count]:=buf;
end;
Close(f);
writeln('Maximalnyi element: ',Max);
writeln('Minimalnyi element: ',Min);
srednee:=srednee/Count;
writeln('Srednee arifmeticheskoe: ',srednee:6:2);
end.
После begin в:
while (not eof(f)) and (Count < n) do
begin
не хватает:
inc(Count);
readln(f,buf);