62,614
社区成员
发帖
与我相关
我的任务
分享
/**
*
* @author crose_1988@163.com
*/
public class test {
public static void main(String[] args) {
int[] array = new int[17];
int count = 0;
for (int i=0; i<array.length; i++)
array[i] = 1;
boolean left;
do {
left = false;
for (int i=0; i<array.length; i++) {
if (array[i] == 1) {
left = true;
if (count == 2) {
array[i] = 0;
count = 0;
System.out.println(i + " is left");
} else
count++;
}
}
} while (left);
}
}
import java.util.ArrayList;
public class TestRound {
public static void print(int number,int count) {
ArrayList list = new ArrayList();
for (int i = 1; i <=number; i++) {
list.add(i);
}
for (int i = 1; list.size() > 1; i++) {
if (i % count == 0) {
System.out.print(list.remove(0) + "-->");
} else {
list.add(list.remove(0));
}
}
System.out.println(list.get(0));
}
public static void main(String[] args) {
print(20,3);
}
}