dotfiles/.bin/avg.c

19 lines
353 B
C
Raw Normal View History

2022-12-05 22:26:33 +01:00
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
2022-12-10 08:14:33 +01:00
unsigned long long no = 0;
for (int i=1; i<argc; i++) {
2022-12-10 11:54:09 +01:00
no += strtoull(argv[i], NULL, 10);
2022-12-05 22:26:33 +01:00
}
if (argc < 2)
2022-12-10 08:14:33 +01:00
printf("%lld\n", no);
2022-12-05 22:26:33 +01:00
if (argc > 1)
2022-12-10 11:54:09 +01:00
printf("%.0lld\n", no / (argc - 1) / 1000000);
2022-12-05 22:26:33 +01:00
return 0;
}