Questions tagged [accumulate]

Accumulation refers to the process of repeatedly combining the previously calculated result with the next item, until the supply of items is exhausted.

Accumulation refers to the process of repeatedly combining the previously calculated result with the next item, until the supply of items is exhausted.

When we are interested only in the final result, it is equivalent to left folding; and if we keep the whole sequence of results progressively calculated, it is known as left scan.

319 questions
-2
votes
3 answers

why c++ std accumulate is always return 0

I am trying to use c++ to sum 3 integers from the input, but I keep get 0. Please help thx. vector x; x.reserve(3); cin >> x[0] >> x[1] >> x[2]; int sum = std::accumulate(x.begin(), x.end(), 0); cout << sum << endl; return…
Xiong chenyu
  • 135
  • 1
  • 9
-3
votes
1 answer

Get row name if the accumulated sum is the NEAREST to 30 and reset the sum again

I have a table with 2 columns: input and length. Make a copy of the example sheet. The Ask I want to output the row numbers in a single formula if the accumulated sum of the "Length" B2:B is the closest to 30, Reset the sum, and do the same. the…
Osm
  • 2,699
  • 2
  • 4
  • 26
-3
votes
2 answers

Python String Accumulator

I am trying to write a code that returns a user input as the following example- User input:- hello Return: H-Ee-Lll-Llll-Ooooo Basically, I want each letter increased by 1, a dash between each letter, and the first letter being capital between each…
-3
votes
3 answers

Do accumulate() function in C++ adds negative numbers?

vector nums={1,12,-5,-6,50,3}; int k=4; int n=nums.size(); for(int i=0;i<=n-k;i++) cout<
1 2 3
21
22