Skip to content

Commit

Permalink
Resovle the conflict of the 11_sorts/Sorts.java
Browse files Browse the repository at this point in the history
  • Loading branch information
westGG committed Nov 4, 2018
1 parent bd19818 commit 99ee504
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions java/11_sorts/Sorts.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,16 @@ public static void insertionSort(int[] a, int n) {
// 选择排序,a表示数组,n表示数组大小
public static void selectionSort(int[] a, int n) {
if (n <= 1) return;
<<<<<<< HEAD
for (int i = 0; i < n; ++i) {
// 查找最小值
int minIndex = i;
int minValue = a[i];
for (int j = i; j < n; ++j) {
if (a[j] < minValue) {
minValue = a[j];
=======

for (int i = 0; i < n - 1; ++i) {
// 查找最小值
int minIndex = i;
for (int j = i + 1; j < n; ++j) {
if (a[j] < a[minIndex]) {
>>>>>>> upstream/master
minIndex = j;
}
}

<<<<<<< HEAD
=======
if (minIndex == i)
continue;

>>>>>>> upstream/master

// 交换
int tmp = a[i];
a[i] = a[minIndex];
Expand Down

0 comments on commit 99ee504

Please sign in to comment.