Pagini recente » Cod sursa (job #1991761) | Cod sursa (job #1496441) | Cod sursa (job #1245393) | Cod sursa (job #2519486) | Cod sursa (job #516404)
Cod sursa(job #516404)
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
ifstream in("text.in");
ofstream out("text.out");
char* s = new char[2000001];
int words = 0;
int total = 0;
while (true) {
if (in.getline(s, 2000001) == NULL) break;
int i = -1;
int size = 0;
while (s[++i] != '\0') {
char c = s[i];
// cout << c;
if (c >= 'A' && c <= 'z') {
size++;
continue;
}
if (size != 0) {
words++;
total += size;
size = 0;
}
}
if (size != 0) {
words++;
total += size;
}
}
out << (words ? ((total - (total % words)) / words) : 0);
cout << (words ? ((total - (total % words)) / words) : 0);
return 0;
}