Cod sursa(job #1232905)

Utilizator G_DavidGherghita David G_David Data 24 septembrie 2014 10:57:27
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <fstream>
using namespace std;

int main()
{
    ifstream infile("text.in");
    ofstream outfile("text.out");

    int c = 0, l = 0;
    char c1, c2;

    infile.get(c1);
    infile.get(c2);

    if (isalpha(c1))
    {
        c++;
        l++;
    }

    if (isalpha(c2))
    {
        l++;
        if (c == 0)
        {
            c++;
        }
    }

    c1 = c2;

    while (infile.get(c2))
    {
        if (isalpha(c2))
        {
            l++;
            if (!isalpha(c1))
            {
                c++;
            }
        }
        c1 = c2;
    }

    outfile << l / c;
}