Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
bubble sort
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.Scanner; class Rextester { public static void main(String args[]) { Scanner in=new Scanner(System.in); int a[]=new int [50]; int n=in.nextInt(); for(int i=0;i<n;i++) a[i]=in.nextInt(); for(int j=0;j<n;j++) { for(int k=0;k<n-j-1;k++) { if(a[k]>a[k+1]){ int temp=a[k]; a[k]=a[k+1]; a[k+1]=temp;} } } for(int l=0;l<n;l++) { System.out.println(a[l]); } } }
run
|
edit
|
history
|
help
0
Java Class and Object
LinearSearch
Sample ArrayList
Intersection of Array
생성자
jb14 L
extendd11
1(B)
Random number
++a vs a++ and calculations around different variables