#K6001. Array Cumulative Sum Transformation
Array Cumulative Sum Transformation
Array Cumulative Sum Transformation
You are given an array of positive integers. The task is to transform the array into its cumulative sum form. Formally, given an array \(a = [a_0, a_1, \dots, a_{n-1}]\), you need to modify it in-place such that for every index \(i\) (where \(0 \le i < n\)), the new value becomes:
[ a_i = \sum_{j=0}^{i} a_j ]
After processing the array, you should output the transformed array with elements separated by a single space.
For example, if the input array is [1, 2, 3, 4, 5], the cumulative sum array is [1, 3, 6, 10, 15].
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains a single integer \(n\) representing the number of elements in the array.
- The second line contains \(n\) space-separated positive integers.
outputFormat
Output to stdout the transformed array as \(n\) space-separated integers in a single line, representing the cumulative sum of the original array.
## sample5
1 2 3 4 5
1 3 6 10 15
</p>