You are viewing a single comment's thread. Return to all comments →
No need to set the amount of decimals, it recognises the answers without needing the precise decimal point
void plusMinus(vector<int> arr) { int maxNumber = arr.size(); float zeroCount {0.0f}; float posCount {0.0f}; float negCount {0.0f}; for(int i = 0; i < maxNumber; i++) { if (arr[i] == 0 ) { zeroCount++; } if (arr[i] > 0) { posCount++; } else if (arr[i] < 0) { negCount++; } } std::cout << posCount/maxNumber << std::endl; std::cout << negCount/maxNumber << std::endl; std::cout << zeroCount/maxNumber << std::endl; }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
No need to set the amount of decimals, it recognises the answers without needing the precise decimal point