fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5.  
  6. bool isneg(int nums)
  7. {
  8. bool its;
  9. if(nums > 0)
  10. {
  11. its = true;
  12. }
  13. else if (nums < 0)
  14. {
  15. its = false;
  16. }
  17. return its;
  18. }
  19. int maximumCount(vector<int>& nums) {
  20. int pos,neg;
  21. int size = nums.size();
  22. while(size!= 0)
  23. {
  24. for(const auto& num : nums)
  25. {
  26. if(isneg(num))
  27. {
  28. pos++;
  29. }
  30. else
  31. {
  32. neg++;
  33. }
  34. }
  35. if(neg > pos)
  36. {
  37. return neg;
  38. }
  39. else
  40. {
  41. return pos;
  42. }
  43. size--;
  44. }
  45. }
  46. int main() {
  47.  
  48. vector<int> params ={-2,-1,-1,1,2,3};
  49. cout << maximumCount(params);
  50.  
  51. // your code goes here
  52. return 0;
  53. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
1220562563