Код
program laba91;
uses crt;
const filename='c:\text.txt';
var f:text;
ln:string[80];
i,k,poz,n,m:byte;
s,a:string;
procedure list;
begin
textcolor(15);
writeln('Text of the file');
textcolor(yellow);
reset(f);
while not eof(f) do
begin
readln(f,ln);
writeln(ln);
end;
close(f);
end;
begin
clrscr;
assign(f,filename);
list;
n:=0;
k:=length(ln);
for i:=1 to length(ln) do
begin
poz:=pos(' ',ln);
m:=poz-1;
if i=k then m:=k;
if ln[1]=ln[m] then
begin
n:=n+1;
delete(ln,1,poz);
end
else delete(ln,1,poz);
end;
writeln;
textcolor(7);
writeln(n);
readln;
end.
uses crt;
const filename='c:\text.txt';
var f:text;
ln:string[80];
i,k,poz,n,m:byte;
s,a:string;
procedure list;
begin
textcolor(15);
writeln('Text of the file');
textcolor(yellow);
reset(f);
while not eof(f) do
begin
readln(f,ln);
writeln(ln);
end;
close(f);
end;
begin
clrscr;
assign(f,filename);
list;
n:=0;
k:=length(ln);
for i:=1 to length(ln) do
begin
poz:=pos(' ',ln);
m:=poz-1;
if i=k then m:=k;
if ln[1]=ln[m] then
begin
n:=n+1;
delete(ln,1,poz);
end
else delete(ln,1,poz);
end;
writeln;
textcolor(7);
writeln(n);
readln;
end.