Pagini recente » Cod sursa (job #2431313) | Cod sursa (job #3317255) | Cod sursa (job #1093203) | Cod sursa (job #1190982) | Cod sursa (job #3338893)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
int cnt_words, last_word_length, total_word_length;
void iterate(char ch) {
if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) {
++last_word_length;
} else {
total_word_length += last_word_length;
if (last_word_length) {
++cnt_words;
}
last_word_length = 0;
}
}
int main()
{
char ch;
while (fin.get(ch)) {
iterate(ch);
}
iterate(' ');
fout << total_word_length / cnt_words;
return 0;
}