Advertisement
Guest User

NickSubmissionChallenge2

a guest
Oct 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. void plusMinus(vector<int> arr)
  2. {
  3.     float totalNum = float(arr.size());
  4.     int pos = 0;
  5.     int neg = 0;
  6.     int zer = 0;
  7.  
  8.     for (int i = 0; i < totalNum; i++)
  9.     {
  10.         if (arr[i] < 0)
  11.         {
  12.             neg++;
  13.         }
  14.         else if (arr[i] > 0)
  15.         {
  16.             pos++;
  17.         }
  18.         else
  19.         {
  20.             zer++;
  21.         }
  22.     }
  23.  
  24.     cout << (pos / totalNum) << endl;
  25.     cout << (neg / totalNum) << endl;
  26.     cout << (zer / totalNum) << endl;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement