#include<stdio.h>
int main(){
int a[50];
int i;
int allNum=0,restNum=0,count=0,roundcount=0;
scanf("%d",&allNum);
for(i=0;i<=allNum;i++){
a[i] = i + 1; // 1 2 3 put into;
}
restNum = allNum;
while(restNum > 1){
roundcount = 0;
//遍历数组;
while(roundcount < allNum){
if(a[roundcount]!=0){
count++;
//报数报到3 就给标记一下,然后就restNum 减少人数
if(count==3){
a[roundcount] = 0; // 退出的人标记为0
restNum--;
count=0;
}
}
roundcount++;
}
}
for(i=0;i<allNum;i++){
if(a[i]!=0){
printf("%d",a[i]);
break;//直接结束吧; 输出一个
}
}
return 0;//正常退出程序;
}
2022-05-21 20:15:17
linmanba 2022-11-16 20:02:06 |
6
王文萱 2023-03-11 22:10:28 |
终于懂了!