Cod sursa(job #2615946)

Utilizator loraclorac lorac lorac Data 15 mai 2020 21:21:49
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream>
#include <algorithm>
#include <cstring>
using namespace std;
ifstream cin("text.in");
ofstream cout("text.out");
const int lim=1e6+10;
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])==true)
                ++l,++ind;
        }
        else
        {
            while(ind<n and tip(s[ind])==false)
                ++ind;
        }
    }
    if(cnt==0) cout<<0<<'\n';
    else cout<<l/cnt<<'\n';
    return 0;
}