M1RAI

Inverse_string_recursive

Jan 1st, 2020
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program inverse_string;
  2. uses wincrt;
  3. var
  4. ch:string;
  5.  
  6.  
  7. function swap(ch:string):String;
  8. Begin
  9.         if ch='' then swap:=''
  10.         Else
  11.         begin
  12.                 ch:=' '+ch;
  13.                 ch[1]:= ch[Length(ch)];
  14.                 Delete(ch,Length(ch),1);
  15.                 Swap:= ch[1]+ swap(Copy(ch,2,Length(ch))) ;
  16.         end;
  17. end;
  18.  
  19. begin
  20. readln(ch);
  21. write(swap(ch));
  22. end.
RAW Paste Data