This commit is contained in:
JISAUAY committed 2024-12-02 09:58:35 -06:00
commit ca9736d8ec
122 files changed
+28514

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE *File;
char *Line = malloc(256);
int CurrentCal, MaxCalories, ElfNum, ElfLargest = 0;
File = fopen("input.txt","r");
while(fgets(Line, 10, File))
{
if (atoi(Line) == 0)
{
if (CurrentCal > MaxCalories)
{
MaxCalories = CurrentCal;
ElfLargest = ElfNum;
}
CurrentCal = 0;
ElfNum++;
}
else
CurrentCal += atoi(Line);
}
printf("Elf %d is carrying %d calories of food.", ElfLargest, MaxCalories);
fclose(File);
return 0;
}