赞
踩
package Tuesday;
import java.util.ArrayList;
/**
* Created by Administrator on 2016/8/31.
*/
public class Game {
public static void main(String[]args) {
ArrayList<Integer> persons= new ArrayList<Integer>();
for (int i = 1; i <= 100; i++) {
persons.add(i);
}
int count= 0;
//逢7杀人,不断地循环杀人
while (persons.size()> 1) {
for (int i = 0; i < persons.size(); i++) {
//叫号计数
count++;
if (count % 7 == 0) {
System.out.println(persons.remove(i) + "被杀了");
//确保每一个人会被编号
i--;
}
}
}
System.out.println(persons.get(0)+"活下来的人");
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。