var a,b:String; begin a:='abcde'; b:=逆转(a); end. b的结果是'edcba'
function RemoteString(const str:string):string; var i:integer; begin setlength(result,length(str)); for i:=length(str) downto 1 do result[length(str)-i+1]:=str[i]; end;
//取左边数n个字符 function LeftStr (const S : string; const N : Integer): string; begin Result := Copy (S, 1, N); end;//取字符串中Ch字符左边的内容 function LeftTillStr (const S : string; const Ch : Char): string; var M: Integer; begin M := Pos (Ch, S); if M < 2 then Result := '' else Result := Copy (S, 1, M - 1); end;//取右边数n个字符 function RightStr (const S : string; const N : Integer): string; var M: Integer; begin M := Length (S) - N + 1; if M < 1 then M := 1; Result := Copy (S, M, N); end;//取字符串中Ch字符右边的内容 function RightAfterChStr (const S : String; const Ch : Char): String; var M: Integer; begin M := Pos (Ch, S); if M = 0 then Result := '' else Result := Copy (S, M + 1, Length (S) - M); end;
象这种简单的函数你该学着自己写才对嘛! 别老是找现成的东东. function change(str :string) : string; var i,len : integer; temp : string; begin len := length(str); temp := ''; for i := len downto 1 do begin temp := temp + str[i]; end; result := temp; end;
a,b:String;
begin
a:='abcde';
b:=逆转(a);
end.
b的结果是'edcba'
var
i:integer;
begin
setlength(result,length(str));
for i:=length(str) downto 1 do
result[length(str)-i+1]:=str[i];
end;
Kingron(WinAPI)实现字符串逆转的代码写得不错嘛!
function LeftStr (const S : string; const N : Integer): string;
begin
Result := Copy (S, 1, N);
end;//取字符串中Ch字符左边的内容
function LeftTillStr (const S : string; const Ch : Char): string;
var
M: Integer;
begin
M := Pos (Ch, S);
if M < 2 then Result := ''
else Result := Copy (S, 1, M - 1);
end;//取右边数n个字符
function RightStr (const S : string; const N : Integer): string;
var
M: Integer;
begin
M := Length (S) - N + 1;
if M < 1 then M := 1;
Result := Copy (S, M, N);
end;//取字符串中Ch字符右边的内容
function RightAfterChStr (const S : String; const Ch : Char): String;
var
M: Integer;
begin
M := Pos (Ch, S);
if M = 0 then Result := ''
else Result := Copy (S, M + 1, Length (S) - M);
end;
别老是找现成的东东.
function change(str :string) : string;
var
i,len : integer;
temp : string;
begin
len := length(str);
temp := '';
for i := len downto 1 do
begin
temp := temp + str[i];
end;
result := temp;
end;