-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_array.java
More file actions
62 lines (41 loc) · 1007 Bytes
/
Copy pathinput_array.java
File metadata and controls
62 lines (41 loc) · 1007 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
52
53
54
55
56
57
58
59
60
61
62
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class input_array {
static int min(int x[],int n)
{
int rev=0;
for(int i=1;i<n;i++)
{
rev=Math.min(rev,x[i]);
}
return rev;
}
public static void main(String[] args)
{
int n;
Scanner input= new Scanner(System.in);
System.out.println("Enter the number of elements you want to enter");
n=input.nextInt();
System.out.println("enter the number you want to enter" );
int [] x=new int[n];
for(int i=0;i<n;i++)
{
x[i]=input.nextInt();
}
input.close();
System.out.print("array elements are :"); //array elements
for(int i=0;i<n;i++)
{
System.out.print( +x[i]+ "," );
}
System.out.println();
Arrays.sort(x); // sorting of array
System.out.print("sorted array is : ");
for(int i=0;i<n;i++)
{
System.out.print( +x[i]+ ",");
}
}
}