#include <stdio.h>
#define IN 1 /* внутри слова */
#define OUT 0 /* вне слова */
/* подсчет строк, слов и символов */
int main()
{
int c, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while ((c = getchar()) != EOF) {
++nc;
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);
return 0;
}
#include <stdio.h>
#define IN 1 /* внутри слова */
#define OUT 0 /* вне слова */
/* подсчет слов */
/* Ричи, Керниган */
int main()
{
int c, nw, state;
state = OUT;
nw = 0;
while ((c = getchar()) != EOF) {
if (c == ' ' || c == '\n' || c == '\t')
state = OUT;
else if (state == OUT) {
state = IN;
++nw;
}
}
printf("%d\n", nw);
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
int count=0;
string str;
while (!cin.eof())
{
cin>>str;
count++;
}
cout<<count-1;
return 0;
}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.