Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner read = new Scanner(System.in);
- int size = read.nextInt();
- int array[] = new int[size+1];
- int i = 0;
- while(i < size){
- int tmp = read.nextInt();
- if( i == 0){
- array[i] = tmp;
- }
- else{
- for(int j = 0; j < i; j++){
- if(tmp < array[j]){
- for(int t = i; t > j; t--){
- array[t] = array[t-1];
- }
- array[j] = tmp;
- break;
- }
- if(j == i-1){
- array[i] = tmp;
- }
- }
- }
- i++;
- }
- for(int j = 0; j < size; j++){
- System.out.println(array[j]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement