Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #define INDEX_WEIRDNESS 2
- int main(int argc, char *argv[]) {
- int sz = strtol(argv[1], NULL, 0);
- int killi = strtol(argv[2], NULL, 0);
- int* dudes = (int *) malloc(sz * sizeof(int));
- int checks = 0, dead = 0, first = 1, i;
- while(1) {
- for(i=0;i<sz;i++) {
- if(!first && dudes[i] < 0)
- continue;
- if(dead == (sz - 1)) {
- printf("Survivor: %d\n", (i+INDEX_WEIRDNESS));
- exit(0);
- }
- if(((++checks) % killi) == 0) {
- dudes[i] = -1;
- dead++;
- } else if(first)
- dudes[i] = 1;
- }
- first = 0;
- }
- }
Add Comment
Please, Sign In to add comment