The_Law

Untitled

Dec 14th, 2017
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.86 KB | None | 0 0
  1. program ideone;
  2.  
  3. var
  4. q, i, j, itl, itr: integer;
  5. s: string;
  6. d: string = 'abcdefgh';
  7. fl1, skip: boolean;
  8.  
  9. begin
  10.     read(s);
  11.  
  12.     itr := length(s) - 1;
  13.     itl := itr - 1;
  14.  
  15.     while s[itl] <> ' ' do
  16.     itl := itl - 1;
  17.     itl := itl + 1;
  18.  
  19.     skip := False;
  20.  
  21.     for i := 1 to itl - 1 do
  22.     begin
  23.  
  24.  
  25.     if (s[i] = ' ') and not(skip) then
  26.     begin
  27.         j := i - 1;
  28.  
  29.         while (j > 1) and (s[j - 1] <> ' ') do
  30.             j := j - 1;
  31.  
  32.         fl1 := False;
  33.  
  34.         if itr - itl = i - 1 - j then
  35.             for q := 0 to (itr - itl) do
  36.                 if (s[j + q] <> s[itl + q]) then
  37.                     fl1 := True;
  38.         if itr - itl <> i - 1 - j then
  39.             fl1 := True;
  40.  
  41.         if fl1 then
  42.         begin
  43.             while j < i - 1 do
  44.             begin
  45.                 write(s[j]);
  46.                 j := j + 1;
  47.             end;
  48.  
  49.             write(' ');
  50.         end;
  51.  
  52.         skip := True;
  53.     end;
  54.  
  55.     if (s[i] <> ' ') and (skip) then
  56.         skip := False;
  57.     end;
  58. end.
Advertisement
Add Comment
Please, Sign In to add comment