fork download
  1. #include <stdio.h>
  2.  
  3. #define ARRAY_SIZE 10
  4.  
  5. int main(void) {
  6. int ndigit[ARRAY_SIZE];
  7. int i;
  8. char c;
  9.  
  10. for(i = 0; i < ARRAY_SIZE; ++i)
  11. ndigit[i] = 0;
  12.  
  13. c = '2';
  14. ++ndigit[c - '0'];
  15.  
  16. c = '7';
  17. ++ndigit[c - '0'];
  18.  
  19. printf("Cyfry = ");
  20.  
  21. for(i = 0; i < ARRAY_SIZE; ++i)
  22. printf("%d: %d\n", i, ndigit[i]);
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 9416KB
stdin
Standard input is empty
stdout
Cyfry = 0: 0
1: 0
2: 1
3: 0
4: 0
5: 0
6: 0
7: 1
8: 0
9: 0