Cod sursa(job #1209221)
Utilizator | Data | 17 iulie 2014 12:47:12 | |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.69 kb |
#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;
}