Pagini recente » Cod sursa (job #2425677) | Cod sursa (job #2298834) | Cod sursa (job #3220883) | Cod sursa (job #2975563) | Cod sursa (job #1725835)
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int trim(string s)
{
int words = 0, letters = 0;
bool ok = 0;
for (int i = 0; i < s.size(); i++)
{
if (isalpha(s[i]))
{
letters++;
ok = true;
}
else if (ok == true)
{
words++;
ok = false;
}
}
return letters / words;
}
int main()
{
ifstream f("text.in");
ofstream g("text.out");
string line;
string content;
while (getline(f, line) != NULL)
content.append(line);
g<<trim(content);
return 0;
}