Created
September 13, 2023 03:19
-
-
Save codeperfectplus/2275fefff8bf94a27e3dfda619e8c400 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void plusMinus(vector<int> arr) { | |
float countPositive = 0; | |
float countNegative = 0; | |
float n = arr.size(); | |
for(int i;i<n;i++) { | |
if (arr[i] > 0) | |
countPositive++; | |
else if (arr[i] < 0) | |
countNegative++; | |
} | |
float countZero = n - countNegative - countPositive; | |
cout << setprecision(6) << countPositive/n << endl; | |
cout << setprecision(6) << countNegative/n << endl; | |
cout << setprecision(6) << countZero/n << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment