program file_operation_TWO;
uses crt;
{----------------opisanie peremennux--------------------------------}
type
tovar = record {opredelyem strukturu dannyx TOVARA}
name : string;
cost : real;
num : integer;
end;
var
F1: file of tovar;
s : array[0..100] of tovar;
s1 : tovar;
c : char;
mas:array[0..100] of real;
ch : integer;
n : integer;
{-------------------------------------------------------------------}
{------------------1-procedura vvoda s klaviatury i zapis v massiv-------------------------}
procedure out_mas;
begin
ch:=0;
writeln('1) Vvod c klaviatury veshestvennyx chisel i zapis v file->>>');
writeln('');
repeat
write('Input name: ');
readln(s[ch].name);
write('Input cost: ');
read(s[ch].cost);
write('Input number: ');
readln(s[ch].num);
writeln('');
{ writeln(s[ch].cost);
writeln(s[ch].name);
writeln(s[ch].num);
} ch:=ch+1;
write('Okonchit vvod? y/n: ');
readln©;
until c = 'y';
n:=ch;
writeln('N=',n);
end;
{---------------------------------------------------------------------}
{-----------------2-procedura zapisi massiva v file-------------------------}
procedure out_fil;
var
file_name : string;
begin
file_name:='o123';
ch:=0;
assign(F1, file_name);
rewrite(f1);
reset(F1);
writeln('2) Zapis massiva v file->>>');
writeln('');
repeat
write(F1,s[ch]);
ch:=ch+1;
until ch<n;
end;
{---------------------------------------------------------------------}
{-------------------3-procedura dopolneniy file--------------------------}
procedure dop_fil;
var
file_name : string;
dstr : string;
i,code:integer;
begin
writeln('');
writeln('3) Dopolnenie file->>>');
ch:=0;
code:=0;
file_name:='o123';
assign(F1, file_name);
reset(F1);
writeln('Vvedite dannye dly dopolneniy v file: ');
{---}
write('Input name: ');
readln(s1.name);
write('Input cost: ');
readln(s1.cost);
write('Input number: ');
readln(s1.num);
{---}
write(F1,s1);
close(F1)
end;
{---------------------------------------------------------------------}
{-------------------4-procedura chteniy iz file i vyvod na ekran------}
procedure in_fil;
var
file_name : string;
i,code:integer;
begin
writeln('');
writeln('4) Chtenie iz file i vyvod na ekran->>>');
ch:=0;
code:=0;
file_name:='o123';
assign(F1,file_name);
writeln('qqqqqqqq'); readkey;
{-----ERRORS!--------}
{---------------------}
repeat
read(F1,s1); {padaeettttt!!!!!!}
readkey;
writeln('Name: ',s1.name);
writeln('Cost: ',s1.cost);
writeln('Number: ',s1.num);
until Eof(F1);
close(F1)
end;
{---------------------------------------------------------------------}
{------------------------ocnovnay programma-----------------------------}
begin
{sohranenie dannyx}
clrscr;
out_mas;
readkey;
out_fil;
readkey;
dop_fil;
readkey;
in_fil;
writeln('');
writeln('Press any key...');
readkey;
end.
Сообщение отредактировано: sergey_baltazavr -