Cod sursa(job #1725831)
| Utilizator | Data | 6 iulie 2016 16:04:58 | |
|---|---|---|---|
| Problema | Text | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.7 kb |
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int trim(string s)
{
int a = 0, words = 0, total = 0;
for (int i = 0; i < s.size(); i++)
{
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
a++;
else
{
if (a > 0)
{
words++;
total+= a;
a = 0;
}
}
}
return total / 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;
}
