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
This commit is contained in:
zombie maniac 2022-12-03 08:49:15 -05:00
parent b2ee7d6266
commit f5c13f7262
Signed by: nbrooks211
GPG key ID: F43C85C0DF0C334E

64
C/main.c Normal file
View file

@ -0,0 +1,64 @@
#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;
}