-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathMain.java
More file actions
30 lines (26 loc) · 711 Bytes
/
Copy pathMain.java
File metadata and controls
30 lines (26 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.company;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner abc=new Scanner(System.in);
int n;
System.out.print("ENTER ARRAY SIZE:");
n=abc.nextInt();
int[] arr= new int[n];
System.out.print("ENTER ARRAY ELEMENTS:");
int i,j,temp;
for(i=0;i<n;i++)
arr[i]=abc.nextInt();
for(i=1;i<n;i++)
{
temp=arr[i];
for(j=i;j>0 && arr[j-1]>temp;j--)
{
arr[j]=arr[j-1];
}
arr[j]=temp;
}
for(i=0;i<n;i++)
System.out.print(arr[i]+",");
}
}