Cod sursa(job #1729911)

Utilizator 17thFoxVulpe Elisabeta Lucia 17thFox Data 15 iulie 2016 20:03:39
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.02 kb
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

ifstream fin("text.in");
ofstream fout("text.out");

string line;

int islitera(int i)
{
    if(i<0)
    {
        return false;
    }
    if(isalpha(line[i]))
    //if(('a'<=line[i] && line[i]<='z') || ('A'<=line[i] && line[i]<='Z'))
    {
        return true;
    }
    return false;
}

int main()
{
    int c, l, d;
    c=0;
    l=0;

    //getline (fin,line);

    char cit, lastC = ' ';
    while (!fin.eof())
    {
        fin.get(cit);
//        cout<<cit<<' '<<isalpha(cit)<<'\n';
    //for(int i=0; i<line.size(); i++)
//    {
        if(!isalpha(cit))
        {
            if(isalpha(lastC))
            {
                c++;
            }
        }
        if(isalpha(cit))
        {
            l++;
//            cout<<"da";
        }
        lastC = cit;
    }
//    if(islitera(line.size()-1) == true)
//    {
//        c++;
//    }

    if(c!=0)
    {
        d=l/c;
    }
    else
    {
        d=0;
    }
    fout<<d<<'\n';
    return 0;
}