public int[] SortInt(int[] R) { for (int i = R.Length - 1; i >= 0; i--) { for (int n = 0; n < i; n++) { if (R[n] > R[n + 1]) { int temp; temp = R[n]; R[n] = R[n + 1]; R[n + 1] = temp; } } } return R; }
C#库:冒泡算法
Posted on
It's me, just me.
public int[] SortInt(int[] R) { for (int i = R.Length - 1; i >= 0; i--) { for (int n = 0; n < i; n++) { if (R[n] > R[n + 1]) { int temp; temp = R[n]; R[n] = R[n + 1]; R[n + 1] = temp; } } } return R; }