forked from thisisshub/HacktoberFest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuick.java
More file actions
36 lines (34 loc) · 718 Bytes
/
Quick.java
File metadata and controls
36 lines (34 loc) · 718 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
31
32
33
34
35
36
import java.util.Scanner;
class Insertion
{
public static void sorting(int A[])
{ int n = A.length;
int i,j,t;
for(i=1;i<n;i++)
{
j=i-1;
t=A[i];
while(j>-1 && A[j]>t)
{
A[j+1]=A[j];
j--;
}
A[j+1]=t;
}
}
public static void main(String[]args)
{
Scanner sc = new Scanner(System.in);
int x,y;
System.out.println("enter the number of integer elements:");
x = sc.nextInt();
int A[]=new int[x];
System.out.println("enter the elements:");
for(y=0;y<x;y++)
A[y] = sc.nextInt();
sorting(A);
System.out.println("elements after sorting:");
for(y=0;y<x;y++)
System.out.print(A[y]+",");
}
}