fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include<bits/stdc++.h>
  4. typedef long long int ll;
  5. int main() {
  6. // your code goes here
  7. int n ; cin>>n;
  8. int i = 1 ;
  9. ll arr[n+1];
  10. ll dp[n+1];
  11. while(i<=n){
  12. cin>>arr[i];
  13. i++;
  14. }
  15. dp[1]=arr[1];
  16. i=2;
  17. while(i<=n){
  18. dp[i]=dp[i-1]+arr[i];
  19.  
  20. i++;
  21. }
  22. i=1;
  23. while(i<=n){
  24. cout<<dp[i]<<endl;
  25. i++;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5292KB
stdin
5
1 2 3 4 5
stdout
1
3
6
10
15