accumulator.cpp 423 B

12345678910111213141516171819
  1. #include <iostream>
  2. #include <numeric>
  3. #include <string>
  4. int main()
  5. {
  6. // This is a compiler feature
  7. int testArr[140] = {[0 ... 139]=10};
  8. printf("%lu\n", sizeof(testArr));
  9. for (size_t i = 0; i <= 2; i++)
  10. {
  11. std::cout << testArr[i] << std::endl;
  12. }
  13. // the initial value must be float
  14. float arrSum = std::accumulate(testArr, testArr + 140, 0.0);
  15. std::cout << arrSum << std::endl;
  16. }