Nu aveti permisiuni pentru a descarca fisierul grader_test6.ok
Cod sursa(job #2022678)
Utilizator | Data | 16 septembrie 2017 22:46:28 | |
---|---|---|---|
Problema | Text | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.83 kb |
#include <fstream>
using namespace std;
ifstream cin("text.in");
ofstream cout("text.out");
int main()
{
ios_base::sync_with_stdio(0);
long long s=0,st=-1,nr=0,i=1;
bool cuv=0;
char ch;
while(1)
{
ch=cin.get();
if(ch=='\n')
{
if(cuv==1)
{
s+=i-st;
nr++;
}
break;
}
bool is=0;
if('a'<=ch and ch<='z')
is=1;
if('A'<=ch and ch<='Z')
is=1;
if(cuv==0 and is==1)
{
cuv=1;
st=i;
}
if(cuv==1 and is==0)
{
cuv=0;
s+=i-st;
nr++;
}
i++;
}
if(nr==0)
cout<<0;
else
cout<<s/nr;
return 0;
}