private static void ReverseArray(int[] array)
{
int temp;
int count = array.Length;
for (int i = 0; i < count/2; i++)
{
temp = array[count - 1 - i];
array[count - 1 - i] = array[i];
array[i] = temp;
}
}
//Test
int[] oldArray = new int[] { 3, 4, 6, 7, 33, 56, 5, 12, 100 };
Console.WriteLine("Before reverse:");
foreach (int element in oldArray)
{
Console.Write(element + ",");
}
ReverseArray(oldArray);
Console.WriteLine();
Console.WriteLine("After reverse:");
foreach (int element in oldArray)
{
Console.Write(element + ",");
}
Console.ReadLine();
PS:怎么这么慢,一张几K的图片传了10多分钟,真够郁闷的,算了,不上图了,NND
请发表评论