![]()
|
NAME
DESCRIPTION
EXAMPLES
chan STDIN; /* requires Spin version 3.1 or later */
init {
int c, nl, nw, nc;
bool inword = false;
do
:: STDIN?c ->
if
:: c == -1 -> break /* EOF */
:: c == '\n' -> nc++; nl++
:: else -> nc++
fi;
if
:: c == ' ' || c == '\t' || c == '\n' ->
inword = false
:: else ->
if
:: !inword ->
nw++; inword = true
:: else /* do nothing */
fi
fi
od;
printf("%d\t%d\t%d\n", nl, nw, nc)
}.P2
|