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

var s:string; min:byte; c:char; t:text;
begin
 assign(t,'c:\file.txt');
 reset(t);
 min:=255;
repeat
 read(t,c);
 s:='';
 while (c<>',') and (c<>'.') and (not eoln(t)) do
  begin
   s:=s+c;
   read(t,c);
  end;
 if eoln(t) then readln(t);
 if length(s)<min then min:=length(s);
until c='.';
close(t);
reset(t);
repeat
 read(t,c);
 s:='';
 while (c<>',') and (c<>'.') do
  begin
   s:=s+c;
   read(t,c);
  end;
 if eoln(t) then readln(t);
 if length(s)=min then write(s,'  ');
until c='.';
close(t);
end.

Leave a Comment

76 − 73 =