-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectiin.java
More file actions
51 lines (33 loc) · 888 Bytes
/
Selectiin.java
File metadata and controls
51 lines (33 loc) · 888 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.*;
class Selection{
void Ssort(int[] ar){
for(int i=0;i<ar.length-1;i++){
int min = i;
for(int j=i+1;j<ar.length;j++){
if(ar[j]<ar[min]){
min = j;
}
}
int temp = ar[min];
ar[min] = ar[i];
ar[i] = temp;
}
for(int i=0;i<ar.length;i++){
System.out.println(ar[i]);
}
}
}
public class array {
public static void main(String[] args) {
Scanner nt = new Scanner(System.in);
System.out.println("Enter the arry size");
int n = nt.nextInt();
int[] arr = new int[n];
System.out.println("Enter the array value");
for(int i=0;i<arr.length;i++){
arr[i]=nt.nextInt();
}
Selection obj =new Selection();
obj.Ssort(arr);
}
}