fork download
  1. #include <stdio.h>
  2.  
  3. /* count digits, white space, others */
  4.  
  5. int main(){
  6. int c, i, nwhite, nother;
  7.  
  8.  
  9.  
  10. int ndigit[10];
  11. nwhite = nother = 0;
  12. for (i = 0; i < 10; ++i)
  13. ndigit[i] =0;
  14. while ((c = getchar()) != EOF)
  15. if (c >= '0' && c <= '9'){
  16. ++ndigit[c-48];
  17. printf("%d\n",c);
  18. }
  19. else if (c == ' ' || c == '\n' || c == '\t')
  20. ++nwhite;
  21. else
  22. ++nother;
  23.  
  24. printf("digits =");
  25. for (i = 0; i < 10; ++i)
  26. printf(" %d", ndigit[i]);
  27. printf(", white space = %d, other = %d\n",
  28. nwhite, nother);
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 2252KB
stdin
abc12323
stdout
49
50
51
50
51
digits = 0 1 2 2 0 0 0 0 0 0, white space = 0, other = 3