TQC+ JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JPA05 { | |
public static void main(String[] argv) { | |
int[] data = {1, 3, 2, 5, 4, 6}; | |
sort(data); | |
} | |
public static void sort(int []data) { | |
for(int i=0;i<data.length-1;i++) { | |
for(int j=i+1;j<data.length;j++) { | |
if(data[i] > data[j]) { | |
int temp = data[i]; | |
data[i] = data[j]; | |
data[j] = temp; | |
} | |
} | |
show(data); | |
} | |
} | |
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