Cod sursa(job #2615945)

Utilizator loraclorac lorac lorac Data 15 mai 2020 21:17:35
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <fstream>
#include <algorithm>
#include <cstring>
using namespace std;
ifstream cin("text.in");
ofstream cout("text.out");
const int lim=1e6+3;
char s[lim];
bool tip(char ch)
{return ((ch>='a' and ch<='z') or (ch>='A' and ch<='Z'));}
int main()
{
    int n,cnt,l,ind;
    cin.getline(s,lim);
    n=strlen(s);
    cnt=l=ind=0;
    while(ind<n)
    {
        if(tip(s[ind]))
        {
            ++cnt;
            while(ind<n and tip(s[ind]))
                ++l,++ind;
        }
        while(ind<n and !tip(s[ind]))
            ++ind;
    }
    if(cnt==0) cout<<0<<'\n';
    else cout<<l/cnt<<'\n';
    return 0;
}