29 lines
486 B
C
29 lines
486 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <limits.h>
|
||
|
|
||
|
int main() {
|
||
|
|
||
|
FILE *input = fopen("input", "r");
|
||
|
|
||
|
if(input == NULL) {
|
||
|
printf("oh noes couldn't open the input file lol\n");
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
|
||
|
char line[255];
|
||
|
int count = 0, last_num = INT_MAX;
|
||
|
while(fgets(line, sizeof(line), input) != NULL) {
|
||
|
int cur_num = atoi(line);
|
||
|
|
||
|
count += cur_num > last_num;
|
||
|
last_num = cur_num;
|
||
|
}
|
||
|
|
||
|
fclose(input);
|
||
|
|
||
|
printf("There were %d measurements larger than the last.\n", count);
|
||
|
|
||
|
}
|