diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-07-08 19:54:42 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-07-08 19:54:42 +0200 |
| commit | dd684349c67c988ef19707cb65e637b6906fac75 (patch) | |
| tree | 2fd9ac45ef08351c8164eda640dade2890f4c731 /HackerRank/PlusMinus | |
| parent | 4688ed5f3a56ac6698250e2169adbfbe53b8b685 (diff) | |
| download | competitive-programming-dd684349c67c988ef19707cb65e637b6906fac75.tar.xz competitive-programming-dd684349c67c988ef19707cb65e637b6906fac75.zip | |
Solved some new problems
Diffstat (limited to 'HackerRank/PlusMinus')
| -rwxr-xr-x | HackerRank/PlusMinus/main | bin | 0 -> 27064 bytes | |||
| -rw-r--r-- | HackerRank/PlusMinus/main.cpp | 24 | ||||
| -rw-r--r-- | HackerRank/PlusMinus/main_input0.txt | 4 | ||||
| -rw-r--r-- | HackerRank/PlusMinus/main_output0.txt | 3 |
4 files changed, 31 insertions, 0 deletions
diff --git a/HackerRank/PlusMinus/main b/HackerRank/PlusMinus/main Binary files differnew file mode 100755 index 0000000..808d60e --- /dev/null +++ b/HackerRank/PlusMinus/main 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 <bits/stdc++.h> + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + vector<int> 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); +} diff --git a/HackerRank/PlusMinus/main_input0.txt b/HackerRank/PlusMinus/main_input0.txt new file mode 100644 index 0000000..db80860 --- /dev/null +++ b/HackerRank/PlusMinus/main_input0.txt @@ -0,0 +1,4 @@ +STDIN Function +----- -------- +6 arr[] size n = 6 +-4 3 -9 0 4 1 arr = [-4, 3, -9, 0, 4, 1] diff --git a/HackerRank/PlusMinus/main_output0.txt b/HackerRank/PlusMinus/main_output0.txt new file mode 100644 index 0000000..b098de6 --- /dev/null +++ b/HackerRank/PlusMinus/main_output0.txt @@ -0,0 +1,3 @@ +0.500000 +0.333333 +0.166667 |
