-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection.java
More file actions
51 lines (47 loc) · 824 Bytes
/
selection.java
File metadata and controls
51 lines (47 loc) · 824 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.io.*;
class selection
{
int n;
int a[]=new int[8];
void input() throws Exception
{
DataInputStream f=new DataInputStream(System.in);
System.out.println("ENTER THENO OF ELEMENTS:");
n=Integer.parseInt(f.readLine());
System.out.println("ENTER THe elements:");
for(int i=0;i<n;i++)
a[i]=Integer.parseInt(f.readLine());
}
void out()
{
int i,j,min,c;
for(i=0;i<n;i++)
{
min=i;
for(j=i+1;j<n;j++)
{
if(a[min]>a[j])
min=j;
}
c=a[min];
a[min]=a[i];
a[i]=c;
}
}
void vijay()
{
System.out.println(" ELEMENTs are arranged:");
for(int i=0;i<n;i++)
System.out.println(a[i]);
}
}
class m
{
public static void main(String v[]) throws Exception
{
selection s=new selection();
s.input();
s.out();
s.vijay();
}
}