實現效果:
實現原理:
實現代碼:
//定義冒泡排序方法 public int[] sory(int[] intArray) { for(int i=0;i<intArray.Length-1;i++){ for (int j = 0; j < intArray.Length - i;j++ ) { if (intArray[i] > intArray[i+1]) { int temp = intArray[i]; intArray[i] = intArray[i+1]; intArray[i+1] = temp; } } } return intArray; }