Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.   int wordlength, c;
  6.  
  7.   while((c = getchar()) != EOF)
  8.   {
  9.     if (c == '\n')
  10.     {
  11.       //show the histogram
  12.     }
  13.     else if(c == ' ') // found a new word
  14.     {
  15.       printf("\t%i\n", wordlength);
  16.       wordlength = 0;
  17.     }
  18.     else if (c != ' ') //found a char
  19.     {
  20.       putchar(c);
  21.       ++wordlength;
  22.     }
  23.    
  24.   }
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement