天蓬老师2017-04-17 13:06:34
https://msdn.microsoft.com/en-us/library/he2s3bh7(v=vs.110).aspx
題主想太多了,鍊錶類別.net裡面是現成的。
怪我咯2017-04-17 13:06:34
陣列大小不可變啊
public int[] InserFunction(int[] inarr, int data, int position)
{
int[] outarr = new int[inarr.Length + 1];
outarr[inarr.Length] = data;
for (int ini = 0; ini < inarr.Length; ++ini) outarr[ini] = inarr[ini];
for (int i = inarr.Length; i > position; --i)
{
int ex = outarr[i];
outarr[i] = outarr[i - 1];
outarr[i - 1] = ex;
}
return outarr;
}