program ttt;
var
f: file of char;
ch : char;
is_end : boolean;
ast : array of string;
str1 : string;
i : integer;
begin
assign(f,'d:\input.txt'); // файл input.txt должен лежать в корне диска D
reset(f);
i := 0; is_end := false;
while ((not eof(f)) and (not is_end)) do // перебераем файл или до конца, или до тега
begin
str1 := '';
read(f,ch);
while ((ch<>' ') and (ch<>#13) and (ch<>#10) and (ch<>#9) and (not eof(f))) do //составляем слово, отбрасывая пробелы, перевод каретки и Tab
begin
str1 := str1 + ch;
read(f,ch);
end;
if eof(f) then str1 := str1 + ch;
if (str1 <> '
begin
if (str1 <> '') then // добавляем составленное слово в массив строк
begin
i := i + 1;
SetLength(ast,i+1);
ast[i] := str1;
end
end
else is_end := true;
end; // конец перебора файла
close(f);
writeln('всего слов в файле - ',i);
writeln (' -------------------------------------------------------- ');
for i:= 1 to (Length(ast)-1) do writeln('Слово номер ',i:8,' = ',ast[i]); 'вывод всего массива строк
end.
Добавить комментарий