Pagini recente » Cod sursa (job #227140) | Cod sursa (job #2975880) | Cod sursa (job #2696025) | Cod sursa (job #99960) | Cod sursa (job #2718029)
#include <bits/stdc++.h>
using namespace std;
#define OUT 0
#define IN 1
unsigned countWords(char *str)
{
int state = OUT;
unsigned wc = 0;
while(*str)
{
if(*str == ' ' || *str == '\n' || *str == '\t')
state = OUT;
else if(state == OUT)
{
state = IN;
++wc;
}
++str;
}
return wc;
}
int main()
{
freopen("text.in", "r", stdin);
freopen("text.out", "w", stdout);
char text[10000];
cin.getline(text, 100000);
int nr =0;
for(int i = 0; i < strlen(text); i++)
{if((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z'))
nr++;
}
cout << nr/countWords(text) << endl;
return 0;
}