Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 7th, 2018 64 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. /* word counting */
  2.  
  3. #include <stdio.h>
  4.  
  5. #define IN      1  // inside a word
  6. #define OUT     0  // outside a word
  7.  
  8.  
  9. int main (void)
  10. {
  11.     int c, n1, nw, nc, state;
  12.  
  13.     state = OUT;
  14.     n1 = nw = nc = 0;
  15.     while ((c = getchar()) != EOF)
  16.     {
  17.         ++nc;
  18.         if ( c == '\n')
  19.             ++n1;
  20.         if ( c == ' ' || c == '\n' || c == '\t')
  21.             state = OUT;
  22.         else if (state == OUT)
  23.         {
  24.             state = IN;
  25.             ++nw;
  26.         }
  27.     }
  28.  
  29.     printf (" %d %d %d\n", n1, nw, nc);
  30.     return 0;
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top