Skip to content

Instantly share code, notes, and snippets.

@codeperfectplus
Created September 13, 2023 03:19
Show Gist options
  • Save codeperfectplus/2275fefff8bf94a27e3dfda619e8c400 to your computer and use it in GitHub Desktop.
Save codeperfectplus/2275fefff8bf94a27e3dfda619e8c400 to your computer and use it in GitHub Desktop.
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