program CalcChars;
const
a = 97; // ord('a')
z = 122; // ord('z')
var
f:text;
inputfile, str:string;
chars: array[a..z] of Integer;
i,total,totalchars: Integer;
notfound: Boolean;
begin
Writeln;
inputfile := 'f.txt';
assign(f,inputfile);
reset(f);
Writeln('Obrabotka fayla: "',inputfile,'"');
total := 0;
totalchars := 0;
while not Eof(f) do
begin
readln(f,str);
for i := 1 to length(str) do
begin
Inc(total);
if (str[i] in ['a'..'z']) then
begin
Inc(totalchars);
chars[ord(str[i])] := chars[ord(str[i])] + 1;
end;
end;
end;
close(f);
Writeln('Obshee kolichestvo symvolov v tekste : ',total);
Writeln('Obnaruzennye stochnye symvoly:');
notfound := False;
for i := a to z do
begin
if (chars[i] > 0) then
Writeln(Chr(i):2,' (',chars[i], ')')
else
notfound := True;
end;
Writeln('Obshee kolichestvo strochnyh symvolov: ',totalchars);
if notfound then
begin
total := 0;
Write('Symvoly: "');
for i := a to z do
begin
if (chars[i] = 0) then
begin
if (total > 0) then Write(',');
Write(Chr(i));
Inc(total);
end;
end;
Writeln('" - v tekste otsutstvuyut.');
end;
Writeln;
Write('Zakonchili. Nazmite <ENTER> dlya vyhoda iz programmy');
Writeln;
Readln;
end.