public class T1{
public T1() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int peoplenum =50 ;
boolean[] p = new boolean[peoplenum];
int num = 1;
int count = 0;
for(int i=0;i<50;i++){
p[i]=true;
}
while(peoplenum>1 ){
if(count==50){
count=0;
}
if( p[count]==true ){
if(num %3 ==0 ){
p[count]=false;
peoplenum--;
}
num++;
}
count++;
} //end while
for(int i=0;i<50;i++){
if(p[i]==true){
System.out.println(i+1);
}
}
}
}
50个人围成一圈数到3和3的倍数时出圈,问剩下的人是谁?在原来的位置是多少
最新推荐文章于 2022-01-02 12:30:14 发布