如何反转包含数字和字母的字符串,但是我想以相反的顺序输出字母。 (不使用字符串函数)
string = 'Hellow 432'
length = len(string)
output = ""
while length>0:
output += string[length-1]
length = length-1
print (output)
String details = "Hellow 432";
string numeric = "";
string nonnumeric = "";
char[] mychar = details.ToCharArray();
foreach (char ch in mychar)
{
if (char.IsDigit(ch))
{
numeric = numeric + ch.ToString();
}
else
{
nonnumeric =ch.ToString()+ nonnumeric;
}
}
return nonnumeric + numeric;
}