fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int n,count=1,i,j,k=0,sum=0,total=0,count1;
  6. scanf("%d",&n);
  7. int m=n;
  8. int a[n],b[m];
  9. for(i=0;i<n;i++)
  10. scanf("%d",&a[i]);
  11. for(i=0;i<n;i++)
  12. {
  13. total=0;
  14. for(j=i;j<n;j++)
  15. {
  16. if(j<n)
  17. {
  18. sum=0;
  19. count1=0;
  20. for(k=j;k<count+j;k++)
  21. {
  22. sum=sum+a[k];
  23. count1++;
  24. }
  25. if(count==count1)
  26. {
  27. total=sum+total;
  28. }
  29. count++;
  30. }
  31. }
  32. printf("%d ",total);
  33. // b[m-1]=total;
  34. // m--;
  35. }
  36. /*for(m=n-1;m>=0;m--)
  37.   printf("%d ",b[m]);*/
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 9424KB
stdin
5
1 2 3 4 5 6 7 8 9 10 
stdout
1959444930 -376055599 -376033540 630678775 -1328788200