本帖最后由 袁晓俊 于 2014-4-23 10:01 编辑
static void Main(string[] args)
{
Console.WriteLine("将3 a 8 haha 翻转");
String[] str = { "3", "a", "8", "haha" };
if (str.Length % 2 == 0)
{
for (int i = 0; i < str.Length / 2; i++)
{
String s = str;
str = str[str.Length - (i + 1)];
str[str.Length - (i + 1)] = s;
}
}
else if (str.Length % 2 == 1)
{
for (int i = 0; i < (str.Length + 1) / 2; i++)
{
String s = str;
str = str[str.Length - (i + 1)];
str[str.Length - (i + 1)] = s;
}
}
foreach (string ss in str);
Console.WriteLine (str );
Console.ReadKey();
} |
|