Pagini recente » Cod sursa (job #84957) | Cod sursa (job #1280224) | Cod sursa (job #1043024) | Cod sursa (job #1344522) | Cod sursa (job #2914341)
#include <fstream>
#include <cctype>
using namespace std;
int main() {
ifstream fin("text.in");
ofstream fout("text.out");
char c;
int cnt = 0, len = 0, words = 0;
while (fin.get(c)) {
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
cnt++;
} else {
len += cnt;
if (cnt > 0) {
words++;
}
cnt = 0;
}
}
if (words == 0) {
fout << "0";
return 0;
}
fout << len / words;
return 0;
}