How to flip the characters in a string (Views: 29)
Problem/Question/Abstract: How to flip the characters in a string Answer: If you want to take "Hello" and make it "olleH" then use the following: procedure Flip(A: string); var t: Integer; begin Result := ''; for t := Length(A) downto 1 do Result := Result + A[t]; end; If you want to take "abcd" and make it "zyxw" then use the following: procedure Flip(A: string); var t: Integer; begin Result := ''; A := Uppercase(A); {develop others for lower case} for t := 1 to Length(A) do Result := Result + CHR(91 - (ORD(A[t]) - 65)); end; |