Create a gist now

Instantly share code, notes, and snippets.

public class BubbleSort {
public int[] sort(int[] numbers) {
int size = numbers.length;
// 数字配列を昇順に並び替える
for (int i = 0; i < size; i++) {
for (int j = size - 1; i < j; j--) {
if (numbers[j - 1] > numbers[j]) {
int tmp = numbers[j - 1];
numbers[j - 1] = numbers[j];
numbers[j] = tmp;
}
}
}
return numbers;
}
}
@nyoronzoi
Owner

バブルソート

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment