public int[] Arrange(int[] array,int start,int step)
{
if(array==null || step<=0) 
throw new ArgumentException();
ArrayList origin=new ArrayList(array);
ArrayList result=new ArrayList();
while(step<origin.Count)
{
for(int i=start;i<origin.Count;i+=step)
{
result.Add(origin[i]);
origin.RemoveAt(i);
i--;
}
}
int[] intResult=new int[result.Count];
result.CopyTo(intResult);
return intResult;
}//使用方法
private void button1_Click(object sender, System.EventArgs e)
{
int[] array=new int[]{1,2,3,4,5,6,7,8,9,10};
int[] newArray=this.Arrange(array,2,3);
}

解决方案 »

  1.   

    public static int[] Handle(int[] array, int pos){
    int[] bb = new int[array.Length];
    int count = array.Length;
    Buffer.BlockCopy(array, 0, bb, 0, count * 4);
    int i = 0, j = 0;
    int len = count;
    int low = pos - 1;
    while (count > low) {
    if ((i % pos) == low) {
    count--;
    } else {
    bb[j++] = bb[i];
    }
    i++;
    if (i == len) {
    i = 0;
    j = 0;
    len = count;
    }
    }
    int[] res = new int[count];
    Buffer.BlockCopy(bb, 0, res, 0, count * 4);
    return res;
    }实际上,无论你取的是第几个,最后的结果都是这个位置的前面几个值。比如,你取第3个,最后的结果便是第一个和第二个。
      

  2.   

    Buffer.BlockCopy(array, 0, bb, 0, count * 4);
    我看不懂????
      

  3.   

    如果取第三个数,这样调用:
    int[] arr = ....;
    int[] res = Handle(arr, 3);