Переписать из некоторого текстового файла в другой текстовый файл все слова, начинающиеся с буквы «к» и содержащие 6 букв — Pascal(Паскаль)

program PascalGuru;

var
  i: integer;
  t, f: text;
  s: string;

procedure zapisi(s: string);
var
  j, p: integer;
  x: string;
begin
  j := 0;
  repeat
    inc(j);
    p := pos(' ', s);
    x := copy(s, 1, p - 1);
    if p = 0 then
      x := s;
    { x - слово }
    if (x[1] = 'к') and (length(x) = 6) then
      writeln(t, x);
    delete(s, 1, p);
  until p = 0;
end;

{ ---------------------------- }
begin
  assign(f, 'fail.txt');
  reset(f);
  assign(t, 'fail_out.txt');
  rewrite(t);
  i := 0;
  while not eof(f) do
  begin
    readln(f, s);
    inc(i);
    zapisi(s);
  end;

  writeln('Slova uspeshno perepisany...');

  close(f);
  close(t);
  readln;

end.

Leave a Comment

99 − 98 =