Cod sursa(job #3155674)

Utilizator PsyDuck1914Feraru Rares-Serban PsyDuck1914 Data 9 octombrie 2023 11:17:16
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f ("text.in");
ofstream g ("text.out");

string s;
int cnt;


int main()
{
    long long size = 0;
    string aux;
    s.push_back('-');
    while(f >> aux){
        s += aux;
        s += '-';
    }
    s.push_back('-');

    int last = 0;

    for(int i=0; i<s.size(); i++)
        if(isalpha(s[i]))
            size++;



    for(int i=last+1; i<s.size(); i++){
        if(!isalpha(s[i])){
            if(i - last > 1)
                cnt ++;
            last = i;
        }
    }

    if(cnt == 0)
        g << 0;
    else
        g << size/cnt;



    return 0;
}