fork download
  1. #include<stdio.h>
  2. int main(void){
  3. int c;
  4. int numWhite = 0;
  5. int numOther = 0;
  6. int tab['9'+1];
  7.  
  8. for(int i = '0'; i <= '9'; i++){
  9. tab[i] = 0;
  10. }
  11.  
  12. while( (c = getchar()) != EOF){
  13. if( c >= '0' && c <='9'){
  14. tab[c] += 1;
  15. }
  16. else if ( c == ' ' || c == '\n' || c == '\t'){
  17. numWhite++;
  18. }
  19. else{
  20. numOther++;
  21. }
  22. }
  23.  
  24. printf("cyfry = { ");
  25. for(int i = '0'; i <= '9'; i++){
  26. printf("%d, ", tab[i]);
  27. }
  28. printf("}, białe znaki = %d, inne = %d\n", numWhite, numOther);
  29. return 0;
  30. }
Success #stdin #stdout 0s 4408KB
stdin
Ala ma kota 1278
stdout
cyfry = { 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, }, białe znaki = 3, inne = 9