thezxtreme

Untitled

May 11th, 2020
1,223
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     using Numbers = std::vector<int32_t>;
  2.     const Numbers& numbers = { -2, 5, 6, -7, 7, 4, 4, -2, -4, 1, 2, 3 };
  3.     const uint8_t counter = 6;
  4.  
  5.     const auto avr = [&](const Numbers& _numbers, uint8_t _counter) -> float
  6.     {
  7.         float result = 0.0f;
  8.  
  9.         for (std::size_t i(0); i != _numbers.size(); ++i)
  10.         {
  11.             if (!_counter)
  12.                 break;
  13.  
  14.             if ((_numbers[i] & 0x80000000) != 0)
  15.                 continue;
  16.  
  17.             if (_counter) { --_counter; result += _numbers[i]; }
  18.         }
  19.         return result/counter;
  20.     };
  21.  
  22.     std::cout << "Avr: " << avr(numbers, counter) << "\n";
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×