From dd684349c67c988ef19707cb65e637b6906fac75 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Fri, 8 Jul 2022 19:54:42 +0200 Subject: Solved some new problems --- HackerRank/PlusMinus/main.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 HackerRank/PlusMinus/main.cpp (limited to 'HackerRank/PlusMinus/main.cpp') diff --git a/HackerRank/PlusMinus/main.cpp b/HackerRank/PlusMinus/main.cpp new file mode 100644 index 0000000..1d5d7e5 --- /dev/null +++ b/HackerRank/PlusMinus/main.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + vector v(n); + for (auto &x : v) + cin >> x; + double plus = 0, minus = 0, zero = 0; + for (int x : v) { + if (x < 0) { + minus++; + } else if (x > 0) { + plus++; + } else { + zero++; + } + } + printf("%.6f\n%.6f\n%.6f\n", plus / n, minus / n, zero / n); +} -- cgit v1.2.3