summaryrefslogblamecommitdiffstats
path: root/inf/aoc/1.c
blob: 654df06b18294dd66993eef7f255acc277cc7d97 (plain) (tree)
1
2
3
4
5
6
7
8
9







                       
                                                


















                                       
                      
                                     


                                                    
#include <stdio.h>
#include <stdlib.h>
int main (void) {
	char b[64];
	unsigned m = 0;
	unsigned n = 0;
	unsigned o = 0;
	unsigned s = 0;
	while (!ferror(stdin) && !feof(stdin)) {
		fgets(b, 64, stdin);
		if (b[0] == '\n') {
			if (s > m) {
				o = n;
				n = m;
				m = s;
				goto c;
			}
			if (s > n) {
				o = n;
				n = s;
				goto c;
			}
			if (s > o) {
				o = s;
				goto c;
			}
			c:
			s = 0;
		} else
			s += atoi(b);
	}
	printf("%u %u %u sum %u\n", m, n, o, m+n+o);
}