Advertisement
Mary_99

Number of characters type

Nov 25th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.   int c, i , nwhite, nother;
  6.   int ndigit[10];
  7.   nwhite = nother = 0;
  8.   for ( i = 0 ; i < 10; ++i)
  9.     ndigit[i] = 0 ;
  10.   while ( (c = getchar())!= EOF)
  11.     if(c >= '0' && c<= '9')
  12.         ++ ndigit[c - '0'];
  13.     else if (c == ' '|| c == '\n' || c == '\t')
  14.         ++nwhite;
  15.     else ++nother;
  16. //zeby zakonczyc trzeba wpisac ctrl z
  17.     printf("digits = ");
  18.     for ( i = 0 ; i < 10; ++i) printf("%d", ndigit[i]);
  19.         printf("\nwhite characters = %d, other = %d\n", nwhite, nother);
  20.  
  21.  
  22.     getchar();
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement