Заменить синонимами слова в файле — Pascal(Паскаль)

{Заменить синонимами слова в файле}

program ;
var f1,f2,f3:text;
    i,n,k,l:integer;
    s,sout,ss,slovoT,slovo,sinonim:string;
begin assign(f1,'text1.txt');
      assign(f2,'text2.txt');
      assign(f3,'text3.txt');
      rewrite(f1);
      writeln('Введите текст:');
      repeat readln(s);
             writeln(f1,s)
      until s='';
      close(f1);
      reset(f1);
      rewrite(f3);
      while not(eof(f1)) do
        begin readln(f1,s);
              s:=s+' ';
              sout:='';
              while length(s)>0 do
                begin l:=pos(' ',s);
                      slovoT:=copy(s,1,l-1);
                      delete(s,1,l);
                      reset(f2);
                      while not(eof(f2)) do
                        begin readln(f2,ss);
                              k:=pos(',',ss);sinonim:=copy(ss,1,k-1);
                              if sinonim=slovoT
                                 then slovoT:=copy(ss,k+1,length(ss)-k)
                        end;
                      close(f2);
                      sout:=sout+slovot+' '
                end;
              writeln(s);
              writeln(f3,sout)
        end;
        close(f3);
        reset(f3);
        while not(eof(f3)) do
          begin readln(f3,s);
                writeln(s)
          end;
        close(f3);
        readln
end.

Leave a Comment

37 + = 42