This repository has been archived on 2024-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
zombie_2022/C/main.c
zombie f5c13f7262
this is kinda a clusterfuck but it was a lot of fun
when making this i didnt even cheat but i did have to lookup alot of how
to C like how to array or how to make main() im dum
also it clobbers the string with 0 inplace of \n but the prompt didnt
say it had to be neat
2022-12-03 08:49:15 -05:00

64 lines
1.7 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h> //fukn c
int main() {
char zombiestring[69] = {"1000\n2000\n3000\n\n4000\n\n5000\n6000\n\n7000\n8000\n9000\n\n10000"};
char *zombiestringptr = zombiestring;
bool go = true;
char checker;
int arraypointer = 0;
int arraypointerbackup = 0;
// int newlinecount = 0;
int elfcount = 0;
int elf[69];
printf(zombiestring);
while (go == true) {
checker = zombiestring[arraypointer];
if (checker == '\0') {
puts("nulterminator found");
elf[elfcount] += atoi(zombiestringptr+arraypointerbackup);
printf("elf 0: %d\nelf 1: %d\nelf 2: %d\nelf 3: %d\nelf 4: %d\n\nelfcount: %d\n", elf[0], elf[1], elf[2], elf[3], elf[4], elfcount);
arraypointer = 1;
arraypointerbackup = 0;
while(arraypointer <= elfcount) {
if (elf[arraypointer] > elf[arraypointerbackup]) {
arraypointerbackup = arraypointer;
arraypointer++;
} else {
arraypointer++;
}
}
printf("the elf with the most is elf: %d with %d calories", arraypointerbackup, elf[arraypointerbackup]);
return 0;
}
if (checker == '\n') {
zombiestring[arraypointer] = '\0';
elf[elfcount] += atoi(zombiestringptr+arraypointerbackup);
arraypointer++;
if (zombiestring[arraypointer] == '\n') {
elfcount++;
arraypointer++;
}
arraypointerbackup = arraypointer;
} else {
arraypointer++;
}
}
return 0;
}