2 Star 10 Fork 2

CG国斌 / myleetcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
BubbleSort.java 705 Bytes
一键复制 编辑 原始数据 按行查看 历史
CG国斌 提交于 2021-02-02 14:16 . bytedance
package com.hit.basinfo.sort_algorithm;
/**
* author:Charies Gavin
* date:2019/1/7,14:20
* https:github.com/guobinhit
* description: 冒泡排序
*/
public class BubbleSort {
/**
* 冒泡排序
*
* @param nums 待排序数组
*/
public void bubbleSort(int[] nums) {
if (nums != null && nums.length > 1) {
for (int i = nums.length - 1; i > 0; i--) {
for (int j = 0; j < i; j++) {
if (nums[j] > nums[j + 1]) {
int temp = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = temp;
}
}
}
}
}
}
Java
1
https://gitee.com/guobinhit/myleetcode.git
git@gitee.com:guobinhit/myleetcode.git
guobinhit
myleetcode
myleetcode
master

搜索帮助