Pagini recente » Cod sursa (job #2596312) | Cod sursa (job #2545165) | Cod sursa (job #3244742) | Cod sursa (job #3038992) | Cod sursa (job #3159701)
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
string s;
bool IsLetter (char c) {
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}
int main() {
getline(fin, s);
long long wordLen = 0;
long long wordCount = 0;
bool shouldBeNewWord = true;
for (char c : s) {
if (IsLetter(c)) {
if (shouldBeNewWord) {
wordCount++;
shouldBeNewWord = false;
}
wordLen++;
}
else {
shouldBeNewWord = true;
}
}
long long average = wordLen / wordCount;
fout << average << '\n';
return 0;
}