Cod sursa(job #1997210)
Utilizator | Data | 3 iulie 2017 17:26:58 | |
---|---|---|---|
Problema | Text | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <fstream>
#include <cstring>
#define nmax 101
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
void Solve()
{char s[10001],c[10001];
long long sum=0,nr=0;
int n=0,i;
while(fin>>c)
{i=0; n=0; strcpy(s,"");
while(c[i]!=NULL)
{if(c[i]>='a'&&c[i]<='z'||c[i]>='A'&&c[i]<='Z')
{s[n++]=c[i]; s[n]=NULL;}
else
{if(n>0) nr++;
sum+=n; n=0;
strcpy(s,"");
}
i++;
}
if(n>0) {sum+=n; nr++;}
}
if(nr>0) fout<<sum/nr<<endl;
else fout<<0<<endl;
}
int main()
{Solve();
return 0;
}