Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/JPA05.java
Created May 24, 2017

Embed
What would you like to do?
TQC+ JAVA
public class JPA05 {
public static void main(String[] argv) {
int[] data = {2, 4, 3, 5, 7, 6, 9, 1}; // 為排序的資料
int j = 0;
while(j < data.length-1) {
for(int index=0;index<data.length-1;index++) {
if(data[index] > data[index+1]) {
int temp = data[index];
data[index] = data[index+1];
data[index+1] = temp;
}
}
show(data);
j++;
}
}
public static void show(int []data) {
String str = " ";
for(int index=0;index<data.length;index++) {
if(index != data.length-1) {
str += data[index] + " ";
} else {
str += data[index];
}
}
System.out.println(str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.