You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/OqevjJbsN2Q
void plusMinus(vector<int> arr) { double sp, sn, sz, pa = 1.0 / arr.size(); sp = sn = sz = 0; for(int i = 0; i < arr.size(); i++){ if(arr[i] > 0) sp+= pa; else if(arr[i]<0) sn+= pa; else sz+= pa; } cout << setprecision(6) << fixed; cout << sp <<endl; cout << sn <<endl; cout << sz <<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 →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/OqevjJbsN2Q