#include <stdio.h> int main(int argc, const char * argv[]) { int num = 0,i = 0; int a[100] = {}; int killnumber = 0; int count = 0; int m =0; printf("请输入参与的人数:"); scanf("%d",&num); for( i = 0;i <num;i++){ a[i]=i+1; } printf("请输入杀人编号:"); scanf("%d",&killnumber); for(i=0;i<num;i++){ if(a[i]!=0) count ++; if(count==killnumber) {printf("%d",a[i]); a[i]=0; m++; count=0; } if(m==num-1)break; if(i==num-1)i=-1; } printf(" "); printf("最后存活的玩家编号为:"); for(i=0;i<num;i++){ if(a[i] !=0){ printf("%d",a[i]); break; } } return 0; }