class Program
{
static void Main(string[] args)
{
string str = "hello world";
char[] strArr = str.ToCharArray();
Change(strArr, 0, strArr.Length-1);
Console.WriteLine(str.Reverse().ToArray());
Console.ReadKey();
}
public static void Change(char[] strArr, int start, int end)
{
char temp = strArr[start];
strArr[start] = strArr[end];
strArr[end] = temp;
if (++start >= --end)
{
Console.WriteLine(strArr);
}
else
{
Change(strArr, start, end);
}
}
} |