Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- procedure WriteWord(s: string);
- var
- ch: char;
- begin
- if (Length(s) = 0) then
- Exit;
- if (not Odd(Length(s))) then
- begin
- ch := s[1];
- s[1] := s[Length(s)];
- s[Length(s)] := ch;
- writeln(s);
- end;
- end;
- procedure Parse(s, w: string);
- begin
- if (Length(s) = 0) then
- Exit
- else begin
- if (s[1] <> ' ') then
- begin
- w := w + s[1];
- Delete(s, 1, 1);
- Parse(s, w);
- end
- else begin
- Delete(s, 1, 1);
- WriteWord(w);
- //w := '';
- Parse(s, '');
- end;
- end;
- end;
- var
- input: string;
- begin
- writeln('enter the string: ');
- readln(input);
- Parse(input, '');
- readln;
- end.
Add Comment
Please, Sign In to add comment