struct person{
       int number;
       person *prior;
       person *next;
}用又向链表把17人的信息存起来,把表头传入void OutArray(person *head){
int i=0;
person *tp=NULL;
person *cp=head;
while(cp->next!=cp){
if(i==3 && cp->next!=cp){
tp=cp->next;
cp->prior->next=cp->next;
cp->next->prior=cp->prior;
cp=tp;
i=0;
}
else{
i++;
cp=cp->next;
}
} cout<<cp->number;
}

解决方案 »

  1.   


    用j2me写的,最后一个是10号
    int [] people = new int[17]; 
        int lastPeople = 0;
        public void getTheLastPeople(){        
            for(int i = 0; i < people.length; i++){
                people[i] = i+1;
            }
            int count = 0;
            int countLast = 0;
            int j = 0;
            while(true){
                for(j = 0; j < people.length; j++){                
                    if(people[j] != 0){
                        count++;
                        people[j] = count;
                        System.out.println("people[" + j + "] = " + people[j]);
                        if (people[j] % 3 == 0) {
                            people[j] = 0;
                            countLast++;
                            if(countLast == 17){
                                lastPeople = j;
                                return;
                            }
                        }
                    }
                }            
            }
        }