Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.io.PrintStream;
  2. import java.util.Scanner;
  3. public class Main {
  4.     public static Scanner in = new Scanner(System.in);
  5.     public static PrintStream out = System.out;
  6.     public static void main(String[] args) {
  7.         int n = in.nextInt();
  8.         int[] a = new int[n];
  9.         for (int i = 0; i < n; i++) {
  10.             a[i] = in.nextInt();
  11.         }
  12.         sort(a);
  13.     }
  14.  
  15.     static void sort(int[] c) {
  16.         int tmp;
  17.         for (int i = 0; i < c.length; i++) {
  18.             for (int j = c.length-2; j >= 0; j--) {
  19.                 if(c[j] > c[j+1]) {
  20.                     tmp = c[j];
  21.                     c[j] = c[j+1];
  22.                     c[j+1] = tmp;
  23.                     for (int C : c) {
  24.                         System.out.print(C + " ");
  25.                     }
  26.                     System.out.println();
  27.                 }
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement