Pagini recente » Cod sursa (job #2705180) | Cod sursa (job #2573415) | Cod sursa (job #2779132) | Cod sursa (job #740220) | Cod sursa (job #1209221)
#include <cstdio>
using namespace std;
FILE* in;
FILE* out;
bool isLetter(char x)
{
return ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'));
}
int main()
{
in = fopen("text.in", "r");
out = fopen("text.out", "w");
long long wordNo = 0, totalLength = 0;
bool isNewWord = true;
char x;
while(fscanf(in,"%c",&x) != EOF)
{
if(isLetter(x))
{
totalLength++;
if(isNewWord)
{
wordNo++;
}
isNewWord = false;
}
else
{
isNewWord = true;
}
}
fprintf(out, "%lld", totalLength/wordNo);
return 0;
}