function RevertString(const AText:widestring):widestring;vari:integer;P:PWideChar;beginSetLength(Result,length(AText));P:=PWideChar(Result);for i:=Length(Atext) downto 1 dobeginP^:=AText[i];inc(P);end;end;
1 回答

桃花長相依
TA貢獻1860條經驗 獲得超8個贊
//把一個輸入字符串翻轉
function RevertString(const AText:widestring):widestring;
var
i:integer;
P:PWideChar; //寬字符,通常就是UNICODE編碼
begin
SetLength(Result,length(AText)); //長度對齊
P:=PWideChar(Result); //取首地址
for i:=Length(Atext) downto 1 do
begin
P^:=AText[i];//當前指針所指的字符賦值,“倒序”
inc(P); //指針前移
end;
end;
- 1 回答
- 0 關注
- 683 瀏覽
添加回答
舉報
0/150
提交
取消