l14.2b

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2B 代码 · 共 42 行

2B
42
字号
#printWrite a program which counts the number of five letterwords in its input (define a word as anything betweenblanks, tabs or newlines).  Compile and run it, then type "ready".Note that all that is wanted is the total number offive letter words - nothing was said about distinctwords.  Just count the number of times exactly fivecharacters appear between spaces.#once #create RefThis is a passage of text which containsexactly twelve words of five letters.Words may appear at the start or at the finalpart of a line.  Other words show up inthe middle.  Avoid counting seven or eight lettersbut every five must be noted.#usera.out <Ref >xxxgrep 12 xxx >/dev/null#succeed/*	one way to count five letter words */ #include <stdio.h>main(){	int since, wdnum, c;	since = 0;	while ((c=getchar()) != EOF) {		if (c == ' ' || c == '\t' || c == '\n') {			if (since == 5)				wdnum++;			since = 0;		}		else			since++;	}	printf("%d\n", wdnum);}#log#next15.1a 10

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?