We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
voidplusMinus(vector<int>arr){intp=0,n=0,z=0;for(intel:arr){if(el>0)p++;elseif(el<0)n++;elsez++;}doubletotal=arr.size();doublepr=p/total;doublenr=n/total;doublezr=z/total;// Set the output to print 6 decimal placescout<<fixed<<setprecision(6);// Print each result on a new linecout<<fixed<<setprecision(6);cout<<pr<<"\n"<<nr<<"\n"<<zr;}
Cookie support is required to access HackerRank
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 →