Skip to content

Instantly share code, notes, and snippets.

@User0111
Created February 1, 2017 11:23
Show Gist options
  • Save User0111/87dc239355fb5f46077018049330072d to your computer and use it in GitHub Desktop.
Save User0111/87dc239355fb5f46077018049330072d to your computer and use it in GitHub Desktop.
package com.company;
public class Main {
public static void main(String[] args) {
int i,j,tm = 0;
int n=0;
int arr1[] = {12, 14, 5, 80, 8, 16, 40};
for(j=0;j<arr1.length;j++){
n++;
for (i = 0; i < arr1.length-n; i++) {
if (arr1[i] > arr1[i + 1]) {
tm = arr1[i + 1];
arr1[i + 1] = arr1[i];
arr1[i] = tm;
}
}
}
for(i=0;i<7;i++){
System.out.println(arr1[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment