2024-04-21 09:03:21 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define IN 1
|
|
|
|
#define OUT 0
|
|
|
|
|
2024-05-02 09:52:00 -04:00
|
|
|
// counting words from getstream,
|
|
|
|
// doesn't work with backspace
|
|
|
|
// (by design)
|
|
|
|
|
2024-04-21 09:03:21 -04:00
|
|
|
main()
|
|
|
|
{
|
|
|
|
int c, nl, nw, nc, state;
|
|
|
|
nl = nw = nc = 0;
|
|
|
|
while ((c = getchar()) != EOF)
|
|
|
|
{
|
|
|
|
++nc;
|
|
|
|
// We do not handle \b, so words count get messed up if we erase anything
|
|
|
|
if (c == '\n')
|
|
|
|
++nl;
|
|
|
|
if (c == ' ' || c == '\n' || c == '\t')
|
|
|
|
state = OUT;
|
|
|
|
else if (state == OUT)
|
|
|
|
{
|
|
|
|
state = IN;
|
|
|
|
++nw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("%d %d %d\n", nl, nw, nc);
|
|
|
|
}
|
|
|
|
|