Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int sum (int array[], int N) {
- if(N < 0) return 0;
- return array[N] + sum (array, N - 1);
- }
- int main () {
- int N, s = 0;
- scanf("%d",&N);
- int array[N];
- for(int i=0; i<N; i++) {
- scanf("%d",&array[i]);
- array [i] = array[i] > 0 ? array[i] : 0;
- }
- for(int i=0; i<N; i++) {
- s = 0;
- for(int j=0; j<i; j++)
- s += sum (array,j);
- printf("%d\n",s);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment