Guest User

Untitled

a guest
Nov 23rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #define INDEX_WEIRDNESS 2
  4.  
  5. int main(int argc, char *argv[]) {
  6. int sz = strtol(argv[1], NULL, 0);
  7. int killi = strtol(argv[2], NULL, 0);
  8. int* dudes = (int *) malloc(sz * sizeof(int));
  9. int checks = 0, dead = 0, first = 1, i;
  10. while(1) {
  11. for(i=0;i<sz;i++) {
  12. if(!first && dudes[i] < 0)
  13. continue;
  14. if(dead == (sz - 1)) {
  15. printf("Survivor: %d\n", (i+INDEX_WEIRDNESS));
  16. exit(0);
  17. }
  18. if(((++checks) % killi) == 0) {
  19. dudes[i] = -1;
  20. dead++;
  21. } else if(first)
  22. dudes[i] = 1;
  23. }
  24. first = 0;
  25. }
  26. }
Add Comment
Please, Sign In to add comment