fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <numeric>
  4.  
  5. int main() {
  6.  
  7. int arr[5] = {100};
  8.  
  9. std::partial_sum(arr, std::end(arr), arr,
  10. [](int a, int b) {
  11. return a - 20;
  12. });
  13.  
  14. for (auto n : arr)
  15. std::cout << n << std::endl;
  16. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
100
80
60
40
20