Cod sursa(job #2302963)
| Utilizator | Data | 15 decembrie 2018 12:03:33 | |
|---|---|---|---|
| Problema | Text | Scor | 70 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <fstream>
#include <string>
#include <vector>
using namespace std;
ifstream in("text.in");
ofstream out("text.out");
int main()
{
bool twowords=0;
int sum=0,wordcount=0;
vector <string> s;
string word;
while (in >> word)
s.push_back(word);
for (int i=0;i<s.size();i++)
{
for (int j=0;j<s[i].size();j++)
{
if (isalpha(s[i][j]))
++sum;
if (s[i].size()>1 && s[i][j]=='-')
twowords=1;
}
if (twowords)
{
wordcount = wordcount + 2;
twowords=0;
}
else
++wordcount;
}
out << sum/wordcount;
}
