Cod sursa(job #1725835)
| Utilizator | Data | 6 iulie 2016 16:10:36 | |
|---|---|---|---|
| Problema | Text | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#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;
}
