fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. char str[1000] = "tempcrap";
  6.  
  7. scanf( "%[^\n]", str );
  8.  
  9.  
  10. int num, ans = 0, n, pos = 0;
  11. while( sscanf( &str[pos], "%i%n", &num, &n ) == 1 ) {
  12.  
  13. pos += n;
  14. ans += num;
  15.  
  16. }
  17.  
  18. printf( "%i", ans );
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 9432KB
stdin
2 5 12 2
45 2 43
stdout
21