Pagini recente » Cod sursa (job #3230284) | Cod sursa (job #865715) | Cod sursa (job #1401420) | Cod sursa (job #2340496) | Cod sursa (job #3159703)
#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;
}
}
if (wordCount == 0) {
fout << 0 << '\n';
}
else {
long long average = wordLen / wordCount;
fout << average << '\n';
}
return 0;
}