Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ssu.liza_eliseeva.task1;
- import java.util.Scanner;
- public class Main {
- public static void Sort (int [] array)
- {
- int temp;
- int j;
- for(int i = 1; i < array.length; ++i) {
- temp = array[i];
- for( j = i-1; (j >= 0) && (temp < array[j]); j--)
- array[j+1] = array[j];
- array[j+1] = temp;
- }
- }
- public static void main(String[] args) {
- System.out.println("Enter count elements of array: ");
- Scanner in = new Scanner(System.in);
- int count = in.nextInt();
- int [] array = new int[count];
- System.out.println("Enter array: ");
- for( int i = 0; i < count; i++){
- array[i] = in.nextInt();
- }
- Sort(array);
- for(int i = 0; i < count; i++){
- System.out.print(array[i] + " ");
- }
- // write your code here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement