Cod sursa(job #2478488)

Utilizator Florinos123Gaina Florin Florinos123 Data 22 octombrie 2019 10:40:32
Problema Text Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
char s[350];
int n,i,lg,cuv,j,cnt;
int cuvant(char n)
{
    if(n>='a' && n<='z')
        return 1;
    if(n>='A' && n<='Z')
        return 1;
    return 0;
}
int main()
{
    f.getline(s,350);
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        if(cuvant(s[i])==1)
            lg++;
        j=i;
        cnt=0;
        if(cuvant(s[j])==1 && cuvant(s[j+1])==1)
        {
            while(cuvant(s[j])==1)
            {
                cnt++;
                j++;

            }
            i=j;
            if(cnt!=0)
                cuv++;
        }
    }
g<<lg/cuv;

    return 0;
}