Pagini recente » Cod sursa (job #2184779) | Cod sursa (job #2396948) | Cod sursa (job #2861346) | Cod sursa (job #111176) | Cod sursa (job #2810745)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream in("text.in");
ofstream out("text.out");
int words;
int lenght;
bool Letter(char letter)
{
return (letter >= 'a' && letter <= 'z') || (letter >= 'A' && letter <= 'Z');
}
int main()
{
char text[1000000];
in.get(text,999999);
int n = strlen(text);
bool ok = false;
for(int index = 0 ; index < n; index++)
{
if(Letter(text[index])) {
lenght++;
ok = true;
}
else
{
if(ok == true)
{
words++;
ok = false;
}
}
}
if(Letter(text[n-1]))
words++;
if(lenght == 0 || words == 0)
out << 0;
else
out << lenght / words;
return 0;
}