Pagini recente » Cod sursa (job #2977168) | Cod sursa (job #3147190) | Cod sursa (job #1378805) | Cod sursa (job #2702432) | Cod sursa (job #516403)
Cod sursa(job #516403)
#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 size = 0;
int words = 0;
int total = 0;
while (true) {
if (in.getline(s, 2000001) == NULL) break;
int i = -1;
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;
}