forked from NIKHILSINGH1510/java-hello
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection.java.txt
More file actions
38 lines (35 loc) · 767 Bytes
/
selection.java.txt
File metadata and controls
38 lines (35 loc) · 767 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
37
import java.util.Scanner;
public class selection
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n;
System.out.print("\n ENTER THE SIZE OF ARRAY\n");
n=sc.nextInt();
int [] a= new int[n];
System.out.print("Enter numbers in the array : \n");
for(int i=0 ; i<=n-1 ; i++ )
{
a[i]=sc.nextInt();
}
int k;
int gr;
for(int d=0 ; d<=n-1 ; d++){
for(int i=d+1 ; i<=n-1 ; i++)
{
if(a[i]< a[d])
{
gr=a[d];
a[d]=a[i];
a[i]=gr;
}
}
}
System.out.print("\n SORTED OUTPUT \n");
for( int i=0;i<=n-1;i++)
{
System.out.printf("%d ",a[i]);
}
}
}