fork download
  1. #include <inttypes.h>
  2. #include <ctype.h>
  3. #include <stdio.h>
  4.  
  5. int main(void)
  6. {
  7. uintmax_t cumsum = 0, n = 0;
  8. for (int c = EOF; (c = getchar()) != EOF; ) {
  9. if (isdigit(c))
  10. n = n * 10 + (c - '0');
  11. else if (n) { // complete number
  12. cumsum += n;
  13. printf("%" PRIuMAX "\n", cumsum);
  14. n = 0;
  15. }
  16. }
  17. if (n)
  18. printf("%" PRIuMAX "\n", cumsum + n);
  19. return feof(stdin) ? 0 : 1;
  20. }
  21.  
  22.  
Success #stdin #stdout 0s 9432KB
stdin
3
4
5
8
stdout
3
7
12
20