Cod sursa(job #3320660)

Utilizator Cristian2010Baciu Cristian Cristian2010 Data 6 noiembrie 2025 21:53:29
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
int main()
{
char a[1001];
int n = 0, i, contor = 0, litere = 0;
fin.get(a, 1001);
n=strlen(a);
bool in_cuvant = false;
int lungime_cuvant = 0;
for (i=0; i<n; i++)
{
    if (strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZĂÂÎȘȚabcdefghijklmnopqrstuvwxyzăâîșț", a[i]))
    {
        in_cuvant = true;
        lungime_cuvant++;
    }
    else
    {
        if (in_cuvant)
        {
            contor++;
            litere+=lungime_cuvant;
            lungime_cuvant=0;
            in_cuvant=false;
        }
    }
}
if (in_cuvant)
{
    contor++;
    litere+=lungime_cuvant;
}
if (contor == 0)
    fout << 0;
else
    fout << litere / contor;
}