/*
* 笔者:老年痴呆的梦
* 编码:GB 18030
* 语言:C语言
*/
/* 无聊的单词 */
#include <stdio.h>
#define IN 1 /* 在单词内*/
#define OUT 0 /* 在单词外*/
void main ()
{
int c;
short state;
unsigned int line,word,nc;
state = OUT;
line = word = nc = 0;
while ((c = getchar ()) != EOF)
{
++nc;
if (c == '\n')
++line;
/* 每次二选一 */
if (c == ' ' || c == '\n' || c == '\t' || c == ',' || c == '.' || c == '?' || c == '(' || c == ')' || c == ':' || c == ';')
state = OUT;
else if (state == OUT)
{
state = IN;
++word;
}
}
printf ("行数:%d单词数:%d字符数:%d",line,word,nc);
}
/* -1 用 Ctrl + Z */
无聊的单词
最新推荐文章于 2025-04-11 11:38:54 发布