有没有能实现这种排序的:
 1  2   3  4
 8  7   6  5 
 9  10  11 12
 .....

解决方案 »

  1.   

        int count = 1;
        for (int i = 0; i < a.Length; i += 4)
        {
            if (count % 2 == 0)
            {
                swap(ref a[i], ref a[i + 3]);
                swap(ref a[i + 1], ref a[i + 2]);
            }
            count++;
        }
      

  2.   

    前面加上一句
    Array.Sort(a);a是你的数组
      

  3.   


    swap是什么?没用过这个方法
      

  4.   

    螺旋矩阵???用for循环嵌套吧
      

  5.   

    本帖最后由 caozhy 于 2012-05-31 19:04:10 编辑
      

  6.   


    a、b互换
    1 2 3 4 --> 4 2 3 1 --> 4 3 2 1
    两次互换