近来无事,随手翻翻书吧。。。。。
#include<stdio.h> #define OUT 1 #define IN 0 main() { int c, nl, nc, nw, state; nl = nc = nw = 0; state = OUT; while ((c = getchar()) != EOF) { nc ++; if (c == '\n') { nl ++; } if (c == ' ' || c == '\t' || c == '\n') { state = OUT; } else if (state == OUT) { state = IN; nw ++; } } printf("%d\t%d\t%d\n", nl, nw, nc); }
wc的