fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <math.h>
  5.  
  6. int main()
  7. {
  8. int i;
  9. int ch;
  10. char str[512];
  11. fgets(str, sizeof str, stdin);
  12.  
  13. for (i = 0; i <= (strlen(str)); i++)
  14. {
  15. if (isdigit(str[i]))
  16. {
  17. int num = atoi(&str[i]);
  18. if(i && str[i-1]=='-') num *= -1;
  19. printf("%d\n", num);
  20. i += ( num==0 ) ? 1 : (int)log10(abs(num))+1;
  21. }
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 9432KB
stdin
-67 1 2 3     45 5 6 7 0 3 -1234 -0 -9 6789 7
stdout
-67
1
2
3
45
5
6
7
0
3
-1234
0
-9
6789
7