-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem3.java
44 lines (25 loc) · 898 Bytes
/
Problem3.java
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
package sheetArrays;
import java.util.Arrays;
import java.util.Scanner;
public class Problem3 {
public static void main(String[] args) {
System.out.println("Enter size of integer array : ");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] arr = new int[n];
int count_0=0;
//int count_1=0;
for (int i = 0; i < n; i++) {
System.out.println("Enter value : ");
arr[i] = in.nextInt();
if(arr[i]==0)count_0++;
}
for (int i = 0; i < count_0; i++) {
arr[i]=0;
}
for (int i =count_0; i < n; i++) {
arr[i]=1;
}
System.out.println(Arrays.toString(arr));
}
}