fork download
  1. #include<stdio.h>
  2.  
  3. int main(){
  4. long int a, *w, tab[100000];
  5. w = tab +1;
  6. while(scanf("%ld", &a)!=EOF){
  7. if(a == 0) {
  8. printf("%ld\n", *w);
  9. tab[0]+= *(w++);
  10. }
  11. *w += a;
  12. }
  13. printf("%ld", tab[0]);
  14. return 0;
  15. }
Success #stdin #stdout 0s 2996KB
stdin
    11 8 2 -1 0
    6 33 -9 10 0
    0
stdout
20
40
0
60