Cod sursa(job #1050367)
| Utilizator | Data | 8 decembrie 2013 15:37:03 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <cstdio>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
freopen("text.in", "r", stdin);
freopen("text.out", "w", stdout);
char c;
long long totalLen = 0, wordLen = 0, nWords = 0;
while ( (c = getchar()) != EOF ) {
if (isalpha(c)) {
if (wordLen == 0)
nWords++;
wordLen++;
} else {
totalLen += wordLen;
wordLen = 0;
}
}
if (wordLen != 0) {
totalLen += wordLen;
}
printf("%lld\n", nWords == 0 ? 0 : totalLen/nWords);
return 0;
}