Pagini recente » Cod sursa (job #3142698) | Cod sursa (job #3234990) | Cod sursa (job #2462010) | Cod sursa (job #1274608) | Cod sursa (job #1469408)
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <climits>
#include <list>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
bool conditie(char c) {
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
}
int main() {
//freopen("text.in", "r", stdin);
freopen("text.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
ifstream f("text.in");
int lungime = 0, numarCuvinte = 0, lungimeText = 0;
char text[1500000];
while (true) {
if (f.eof())
break;
f >> noskipws >> text[lungimeText];
lungimeText++;
}
for (int i = 0; i < lungimeText; i++) {
if (conditie(text[i])) {
numarCuvinte++;
for ( ; i < lungimeText && conditie(text[i]); i++)
lungime++;
i--;
}
}
if (numarCuvinte == 0)
cout << 0;
else
cout << lungime / numarCuvinte;
return 0;
}