From e8e801086cfca3a8d036f38bd4fa08c3d54402f4 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Thu, 19 Sep 2024 21:21:28 -0300 Subject: [PATCH] Solve Positives and Average in c --- solutions/beecrowd/1064/1064.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 solutions/beecrowd/1064/1064.c diff --git a/solutions/beecrowd/1064/1064.c b/solutions/beecrowd/1064/1064.c new file mode 100644 index 00000000..61b149ce --- /dev/null +++ b/solutions/beecrowd/1064/1064.c @@ -0,0 +1,20 @@ +#include +#include +#include + +int main() { + float n, s = 0; + int16_t c = 0; + + while (scanf("%f", &n) != EOF) { + if (n > 0) { + s += n; + c++; + } + } + + printf("%d valores positivos\n", c); + printf("%.1f\n", (float)(s / c)); + + return 0; +}