Cod sursa(job #516410)
| Utilizator | Data | 23 decembrie 2010 22:21:41 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <cstdlib>
#include <fstream>
#include <iostream>
using namespace std;
int main() {
ifstream in("text.in");
ofstream out("text.out");
char c;
int words = 0, total_size = 0, size = 0;
while ((c = in.get()) && (c != EOF)) {
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
size++;
total_size++;
} else if (size != 0) {
size = 0;
words++;
}
}
if (size != 0) {
words++;
}
out << (words ? total_size / words : 0);
cout << (words ? total_size / words : 0);
return 0;
}
