伟大航路
pz0513
全部博文(33)
UNIX操作系统设计(1)
Linux程序设计((8)
The C Programmin(8)
Chapter5(5)
2009年(33)
zhanghei
Wins0n
stokeora
分类: C/C++
2009-06-20 17:52:15
#include<stdio.h>#define OUT 0#define IN 1int main(){ int c, nc, nw, ns, nl, nt, state; nc = nw = ns = nl = nt = 0; state = OUT; while((c = getchar()) != EOF){ nc++; if(c == ' ') ns++; else if(c == '\t') nt++; else if(c == '\n') nl++; if(c == ' ' || c == '\t' || c == '\n') state = OUT; else if(state == OUT) state = IN, ++nw; } printf("characters: %d, spaces: %d, words: %d, newlines: %d, tabs: %d\n", nc, ns, nw, nl, nt);}
上一篇:C1 - 1.5.4 Word Counting 单词计数
下一篇:Exercise 1-13
登录 注册