2-7.c
来自「数据结构经典算法一书源代码和习题解答实现代码。」· C语言 代码 · 共 25 行
C
25 行
#include<stdio.h>
#define IN 1
#define OUT 0
void main(void)
{
int c,nl,nw,nc,state;
state=OUT;
nl=nw=nc=0;
printf("input a text end of crtl+z\n");
while((c=getchar())!=EOF)
{
++nc;
if(c=='\n')
++nl;
if(c==' '||c=='\n'||c=='\t')
state=OUT;
else if (state==OUT)
{
state=IN;
++nw;
}
}
printf("lines=%dwords=%d characters=%d\n",nl,nw,nc);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?