bab_mail

http://otvet.mail.ru/question/86610135

Feb 21st, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.71 KB | None | 0 0
  1. {$APPTYPE CONSOLE}
  2.  
  3. uses
  4.   SysUtils;
  5.  
  6. procedure WriteWord(s: string);
  7. var
  8.   ch: char;
  9. begin
  10.   if (Length(s) = 0) then
  11.     Exit;
  12.   if (not Odd(Length(s))) then
  13.   begin
  14.     ch := s[1];
  15.     s[1] := s[Length(s)];
  16.     s[Length(s)] := ch;
  17.     writeln(s);
  18.   end;
  19. end;
  20.  
  21. procedure Parse(s, w: string);
  22. begin
  23.   if (Length(s) = 0) then
  24.     Exit
  25.   else begin
  26.     if (s[1] <> ' ') then
  27.     begin
  28.       w := w + s[1];
  29.       Delete(s, 1, 1);
  30.       Parse(s, w);
  31.     end
  32.     else begin
  33.       Delete(s, 1, 1);
  34.       WriteWord(w);
  35.       //w := '';
  36.       Parse(s, '');
  37.     end;
  38.   end;
  39. end;
  40.  
  41. var
  42.   input: string;
  43. begin
  44.   writeln('enter the string: ');
  45.   readln(input);
  46.   Parse(input, '');
  47.   readln;
  48. end.
Add Comment
Please, Sign In to add comment