В исходном текстовом файле в каждой строке найти самое большое слово и вывести его в результирующий файл.Разделители: точка, пробелы, запятая — Pascal(Паскаль)

uses crt;
const razd:set of char=[' ','.',','];
var count,i,max,n:integer;
    st,buf:string;
    slova:array[1..100]of string;
begin
 clrscr;
 write('-> ');
 readln(st);
 count:=1;
 repeat
  if (st[1] in razd) or (length(st)=1) then while st[1] in razd do delete(st,1,1)
  else
  begin
   while (not(st[1] in razd)) and (length(st)>1) do
   begin
    buf:=buf+st[1];
    delete(st,1,1);
   end;
  slova[count]:=buf;
  buf:='';
  inc(count);
  end;
 until (length(st)=1) and (length(buf)=0);
 
 max:=0;
 for i:=1 to count-1 do
 begin
  if length(slova[i])>max then
  begin
   max:=length(slova[i]);
   n:=i;
  end;
 end;
 writeln(slova[n]);
 readln;
end.

Leave a Comment

+ 70 = 80