advent-of-code-2021/1/1-1.c
2021-12-04 21:30:27 +08:00

22 lines
468 B
C

#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
int main(int argc, char const *argv[])
{
FILE *p_file = fopen("input", "r");
char line[50];
unsigned int increases = 0;
unsigned int previous_depth = 0;
while (fgets(line, sizeof line, p_file) != NULL)
{
if (atoi(line) > previous_depth)
{
increases++;
}
previous_depth = atoi(line);
}
printf("%u\n", increases - 1);
return 0;
}