-
Notifications
You must be signed in to change notification settings - Fork 0
/
BulleSort
44 lines (36 loc) · 1.12 KB
/
BulleSort
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package yexin.java.base;/**
* Company: Huazhong University of science and technology
* 华中科技大学电气学院聚变与等离子体研究所
* Version: V1.0
* Author: Victor
* Contact: 1650996069@qq.com 2018--2020
* Software: IntelliJ IDEA
* File: MaopaoSort
* Time: 2019/2/25 20:11
* Desc:
**/
public class MaopaoSort {
public static void main(String[] args) {
int[] intArray = {12,45,2,3,78,34,1,9,5};
System.out.println("排序之前的数组:");
for(int a : intArray){
System.out.print(a+" ");
}
System.out.println();
int tmp = 0;
for(int i=0;i < intArray.length;i++){
for(int j=i;j < intArray.length;j++){
if(intArray[j] < intArray[i]){
//在内循环里面交换才是冒泡排序!!!
tmp = intArray[i];
intArray[i] = intArray[j];
intArray[j] = tmp;
}
}
}
System.out.println("排序后的数组:");
for(int b:intArray){
System.out.print(b+" ");
}
}
}