-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain10.java
More file actions
36 lines (35 loc) · 828 Bytes
/
Main10.java
File metadata and controls
36 lines (35 loc) · 828 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
/**
* Created by LXF on 2017/8/15.
*/
public class Main10 {
public static void main(String[] args) {
int[] array = new int[]{0, 1, 2, 3, 4, 5};
int n = array.length;
int[] isdel = new int[n];
int k = 0;
for (int i = 0; ; i = (i+1) % n) {
if (isdel[i] == 0) {
k++;
}
if (k == 3) {
isdel[i]=1;
k=0;
if (getSum(isdel) == n-1) {
break;
}
}
}
for (int i = 0; i < n; i++) {
if (isdel[i] == 0) {
System.out.println(i);
}
}
}
public static int getSum(int[] a) {
int sum = 0;
for (int i : a) {
sum += i;
}
return sum;
}
}