Cod sursa(job #2022677)

Utilizator FunnyStockyMihnea Andreescu FunnyStocky Data 16 septembrie 2017 22:41:46
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 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++;
    }
    cout<<s/nr;
    return 0;
}