#include<stdio.h>
#define N 100
void Joseph(int g[N], int t, int n, int k) {
printf("Please enter the number of participants in the game:");
scanf("%d", &t);
printf("\nPlease enter the game start number:");
scanf("%d", &n);
printf("\nPlease enter death number:");
scanf("%d", &k);
int num = 0; //记录报数;
int death = 0; //记录淘汰的人数;
int i = 0; //记录第几个被淘汰的玩家;
while (death != (t - 1))
{
if (g[n] == 0){
num++;
if (num == k) {
g[n] = 1;
death++;
i++;
num = 0;
printf("The NO.%d player to die is g[%d]!\n", i, n+1);
}
}
n++;
if (n == t)
n = 0;
}
for (int j = 0; j < sizeof(g)/sizeof(g[0]); j++)
//sizeof是一种单目运算符用于计算数据在内存中所占用的空间大小
//g:表示的是数组的地址;
//g[0]:表示的是数组首元素的地址;
//此时sizeof(g)/sizeof(g[0])=整个数组空间的大小;
{
if (g[j] == 0)
printf("Congratulations to player g[%d] for being a survivor!\n", j);
}
}
int main(){
int game[N] = { 0 };
int total = 0; //参加游戏的人数;
int n = 0; //记录起始编号;
int kill = 0; //死亡编号;
Joseph(game, total, n, kill);
return 0;
}