Pagini recente » Cod sursa (job #1424612) | Cod sursa (job #2927592) | Cod sursa (job #2398253) | Cod sursa (job #2024821) | Cod sursa (job #3159713)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
bool IsLetter (char c) {
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}
int main() {
long long wordLen = 0;
long long wordCount = 0;
bool shouldBeNewWord = true;
char c;
while (fin.get(c)) {
if (IsLetter(c)) {
if (shouldBeNewWord) {
wordCount++;
shouldBeNewWord = false;
}
wordLen++;
}
else {
shouldBeNewWord = true;
}
}
fout << wordLen / wordCount << '\n';
return 0;
}