blob: 66633049b67ce2de9340aeb12f5d77e9195d5b15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#print
Write a program which counts the number of five letter
words in its input (define a word as anything between
blanks, tabs or newlines). Compile and run it, then type "ready".
Note that all that is wanted is the total number of
five letter words - nothing was said about distinct
words. Just count the number of times exactly five
characters appear between spaces.
#once #create Ref
This is a passage of text which contains
exactly twelve words of five letters.
Words may appear at the start or at the final
part of a line. Other words show up in
the middle. Avoid counting seven or eight letters
but every five must be noted.
#user
a.out <Ref >xxx
grep 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
#next
15.1a 10
|