uses
..., System.Character;
var
str, result: String;
i: Integer;
ch: Char;
begin
str := ...;
i := 0;
for ch in str do
begin
if not Odd(i) then
result := result + ch.ToUpper
else
result := result + ch.ToLower;
Inc(i);
end;
end;
或者:
uses
..., System.Character;
var
str: String;
i: Integer;
begin
str := ...;
for i := 1 to Length(str) do
begin
if Odd(i) then
str[i] := str[i].ToUpper
else
str[i] := str[i].ToLower;
end;
end;
1条答案
按热度按时间2w3rbyxf1#
通常的方法是迭代字符串,交替使用大写和小写字符,例如:
或者: