Ok, so let's use Mod for finding the poor guy who gets killed and simplify this a little bit to a final program:
Code:
int guy[100], exec_order[100];
int i, guys_num, order, execute_step;
int remaining, tmp_count, position = 0;
printf("Number of men: ");
scanf(%d", &guys_num);
printf("\nTotal number of men: %d", &guys_num);
printf("\nNow enter the order that you would like:\n");
for (i = 0; i < guys_num; i++) {
scanf("%d", &order);
guy[i] = order;
}
printf("\nThe order of men is: ");
for (i = 0; i < guys_num; i++)
printf("\n%d", guy[i]);
printf("\nNow enter the execution step: ");
scanf("%d", &execute_step);
remaining = guys_num;
while (remaining > 0) {
position = position + execute_step;
if (position > remaining - 1)
position = position Mod remaining;
exec_order[guys_num - remaining] = guy[position];
tmp_count = 0;
for (i = 0; i < remaining; i++) {
if (i == position)
i++;
if (i >= remaining)
break;
guy[tmp_count] = guy[i];
tmp_count++;
}
remaining--;
position--;
if (position < 0)
position = remaining - 1;
}
printf("\nThe order they were executed in is:\n");
for (i = 0; i < guys_num; i++)
printf("\n%d", exec_order[i]);
Tell me if this works. I did this because my server is currently down and I have all my code there so I currently cant' work on my stuff. Can you see I'm bored? I don't even have a compiler here so I don't expect the code above to be free of syntax errors.