Nu aveti permisiuni pentru a descarca fisierul grader_test2.ok
Cod sursa(job #516396)
Utilizator | Data | 23 decembrie 2010 21:45:34 | |
---|---|---|---|
Problema | Text | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.77 kb |
#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];
in.getline(s, 2000001);
int size = 0;
int words = 0;
int total = 0;
int i = 0;
while (s[i] != '\0') {
char c = s[i];
if (c >= 'A' && c <= 'z') {
size++;
i++;
continue;
}
if (size != 0) {
words++;
total += size;
size = 0;
}
i++;
}
if (size != 0) {
words++;
total += size;
}
out << (words ? ((total - (total%words)) / words) : 0);
cout << (words ? ((total - (total%words)) / words) : 0);
return 0;
}