#include<stdio.h>
#include<math.h>
void Round(int *arr,int n);
void SearchLast(int *arr,int n);
int main(void){
int arr[4];
Round(arr,4);
SearchLast(arr,4);
}
void Round(int *arr,int n){
int flag=n;int i=0;
for(i=0;i<n;i++)//Initialize
*(arr+i)=i+1;
int count=0;
i=0;
int round=0;
while(flag>1){
/*
round++;
printf("round %d:",round);
for(int k=0;k<n;k++){
printf(" %d",arr[k]);
}
printf("\n");
*/
while(i<=n){
if(i==n){i=0;}
if(arr[i]==i+1&&count<3){
count++;
if(count==3){
count=0;arr[i]=0;flag--;
}
i++;
break;
}
i++;
}
}
}
void SearchLast(int *arr,int n){
for(int i=0;i<n;i++)
if(*(arr+i)==i+1)
printf("the last is %d.\n",i);
}
标签:arr,int,每报,报数,Round,void,round,指针
From: https://www.cnblogs.com/zhongta/p/18200334