Pagini recente » Cod sursa (job #1866178) | Cod sursa (job #1564656) | Cod sursa (job #1934708) | Cod sursa (job #958012) | Cod sursa (job #3159698)
#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);
int wordLen = 0;
int wordCount = 0;
bool shouldBeNewWord = true;
int sum = 0;
for (char c : s) {
if (IsLetter(c)) {
if (shouldBeNewWord) {
wordCount++;
shouldBeNewWord = false;
}
wordLen++;
}
else {
shouldBeNewWord = true;
}
}
int average = wordLen / wordCount;
fout << average << '\n';
return 0;
}