fork download
  1. #include <stdio.h>
  2.  
  3. #define IN 1 /*Внутри слова*/
  4. #define OUT 0 /*Снаружи слова*/
  5.  
  6. int main(void) {
  7. int c, nl, nw, nc, state; /*Количество строк, слов и сиволов*/
  8.  
  9. state = OUT;
  10. nl = nw = nc = 0;
  11. while((c = getchar()) != EOF){
  12. ++nc;
  13. if(c == '\n')
  14. ++nl;
  15. if(c == ' ' || c == '\n' || c == '\t')
  16. state = OUT;
  17. else if(state == OUT){
  18. state == IN;
  19. ++nw;
  20. }
  21. }
  22.  
  23. printf("%d %d %d\n", nl, nw, nc);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 2012KB
stdin
a b c def
     g
     h
i
stdout
3 9 25