abc->cba
Console.WriteLine("请输入:");
string str = Console.ReadLine();
char[] chs = str.ToCharArray();
char[] chs1 = new char[chs.Length];
for (int i = chs.Length - 1, j = 0; i >= 0; i--, j++)
{
chs1[j] = chs[i];
}
string str1 = new string(chs1);
Console.WriteLine(str1);
I Love You->I evoL uoY
Console.WriteLine("请输入:");
string str = Console.ReadLine();
string[] strNew = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < strNew.Length; i++)
{
char[] chs = strNew[i].ToCharArray();
for (int j = 0; j < chs.Length / 2; j++)
{
char temp = chs[j];
chs[j] = chs[chs.Length - 1 - j];
chs[chs.Length - 1 - j] = temp;
}
strNew[i] = new string(chs);
}
str = string.Join(" ", strNew);
Console.WriteLine(str);