fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C/C++.
  5. Code, Compile, Run and Debug online from anywhere in world.
  6.  
  7. *******************************************************************************/
  8. #include <stdio.h>
  9. #include <string.h>
  10.  
  11. int main() {
  12. char str[1001];
  13. int freq[10] = {0};
  14.  
  15. scanf("%s", str);
  16.  
  17. for(int i = 0; str[i] != '\0'; i++) {
  18. if(str[i] >= '0' && str[i] <= '9') {
  19. int digit = str[i] - '0';
  20. freq[digit]++;
  21. }
  22. }
  23.  
  24. for(int i = 0; i < 10; i++) {
  25. printf("%d ", freq[i]);
  26. }
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 5316KB
stdin
45
stdout
0 0 0 0 1 1 0 0 0 0