Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / Pascal.1.курс / part 1 / LABA4 / VAR7 / LABA4_7
.PAS program laba4_var7;
uses crt;
const n=5;
var f:file of integer;
path:string[20];
i,k,m,counter,q,rand:integer;
a:array[1..80] of integer;
begin
clrscr;
(* 1. ЋЇаҐ¤Ґ«ҐЁҐ д ©« *)
textcolor(white);
write('‚ўҐ¤ЁвҐ Ё¬п ᮧ¤ ў Ґ¬®Ј® д ©« : ');
textcolor(green);
readln(path);
assign(f,path);
{$I-}
rewrite(f);
{$I+}
if ioresult<>0 then
begin
textcolor(red);
writeln('Љ ЄЁҐ-в® Їа®Ў«Ґ¬л б д ©«®¬! Press Enter to exit');
readln;
halt;
end;
(* 2. ”®а¬Ёа®ў ЁҐ д ©« *)
textcolor(white);
writeln('‚ўҐ¤ЁвҐ зҐаҐ§ Enter н«Ґ¬Ґвл д ©« (ўбҐЈ® ',n,' н«Ґ¬Ґв®ў):');
textcolor(green);
for i:=0 to n-1 do
begin
seek(f,i);
readln(rand);
write(f,rand);
end;
writeln;
close(f);
textcolor(white);
write('” ©« бд®а¬Ёа®ў ! “¤ «пҐ¬ г«ҐўлҐ н«Ґ¬Ґвл... ');
(* 3. ‘зЁвлў ЁҐ д ©« ў ¬ ббЁў *)
reset(f);
counter:=1;
for i:=1 to filesize(f) do
begin
seek(f,i-1);
read(f,k);
if k<>0 then
begin
a[counter]:=k;
inc(counter);
end;
end;
close(f);
(* 4. ЏҐаҐ§ ЇЁбм д ©« *)
rewrite(f);
for i:=1 to counter-1 do write(f,a[i]);
textcolor(red);
writeln('Done!');
close(f);
(* 5. ‚лў®¤ ЇҐаҐ§ ЇЁб ®Ј® д ©« *)
reset(f);
clrscr;
textcolor(white);
write('Ќ®ўл© д ©«: ');
textcolor(green);
for i:=1 to filesize(f) do
begin
seek(f,i-1);
read(f,m);
write(m,' ');
end;
writeln;
textcolor(cyan);
writeln(' Ќ ¦¬ЁвҐ Enter ¤«п ўл室 Ё§ Їа®Ја ¬¬л...');
readln;
end.
uses crt;
const n=5;
var f:file of integer;
path:string[20];
i,k,m,counter,q,rand:integer;
a:array[1..80] of integer;
begin
clrscr;
(* 1. ЋЇаҐ¤Ґ«ҐЁҐ д ©« *)
textcolor(white);
write('‚ўҐ¤ЁвҐ Ё¬п ᮧ¤ ў Ґ¬®Ј® д ©« : ');
textcolor(green);
readln(path);
assign(f,path);
{$I-}
rewrite(f);
{$I+}
if ioresult<>0 then
begin
textcolor(red);
writeln('Љ ЄЁҐ-в® Їа®Ў«Ґ¬л б д ©«®¬! Press Enter to exit');
readln;
halt;
end;
(* 2. ”®а¬Ёа®ў ЁҐ д ©« *)
textcolor(white);
writeln('‚ўҐ¤ЁвҐ зҐаҐ§ Enter н«Ґ¬Ґвл д ©« (ўбҐЈ® ',n,' н«Ґ¬Ґв®ў):');
textcolor(green);
for i:=0 to n-1 do
begin
seek(f,i);
readln(rand);
write(f,rand);
end;
writeln;
close(f);
textcolor(white);
write('” ©« бд®а¬Ёа®ў ! “¤ «пҐ¬ г«ҐўлҐ н«Ґ¬Ґвл... ');
(* 3. ‘зЁвлў ЁҐ д ©« ў ¬ ббЁў *)
reset(f);
counter:=1;
for i:=1 to filesize(f) do
begin
seek(f,i-1);
read(f,k);
if k<>0 then
begin
a[counter]:=k;
inc(counter);
end;
end;
close(f);
(* 4. ЏҐаҐ§ ЇЁбм д ©« *)
rewrite(f);
for i:=1 to counter-1 do write(f,a[i]);
textcolor(red);
writeln('Done!');
close(f);
(* 5. ‚лў®¤ ЇҐаҐ§ ЇЁб ®Ј® д ©« *)
reset(f);
clrscr;
textcolor(white);
write('Ќ®ўл© д ©«: ');
textcolor(green);
for i:=1 to filesize(f) do
begin
seek(f,i-1);
read(f,m);
write(m,' ');
end;
writeln;
textcolor(cyan);
writeln(' Ќ ¦¬ЁвҐ Enter ¤«п ўл室 Ё§ Їа®Ја ¬¬л...');
readln;
end.