Advertisement
CLazStudio

q200319915

May 2nd, 2017
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.68 KB | None | 0 0
  1. var f1, f2: text;
  2.     i: integer;
  3.     temp: string;
  4.     k: char;
  5.  
  6. const A = 'паровоз';
  7.       B = 'пароход';
  8.  
  9. begin
  10.   Assign(f1, 'input.txt');
  11.   Reset(f1);
  12.  
  13.   Assign(f2, 'output.txt');
  14.   Rewrite(f2);
  15.  
  16.   i := 1;
  17.   temp := '';
  18.   repeat
  19.     read(f1, k);
  20.     if (k = A[i]) then
  21.     begin
  22.       temp := temp + k;
  23.       i := i + 1;
  24.       if (i > Length(A)) then
  25.       begin
  26.         write(f2, B);
  27.         i := 1;
  28.         temp := '';
  29.       end;
  30.     end else begin
  31.       if (i > 1) then begin
  32.         write(f2, temp);
  33.         i := 1;
  34.         temp := '';
  35.       end;
  36.       write(f2, k);
  37.     end;
  38.   until (Eof(f1));
  39.  
  40.   Close(f1);
  41.   Close(f2);
  42. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement