Cod sursa(job #1064068)

Utilizator G_DavidGherghita David G_David Data 21 decembrie 2013 13:44:24
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
    int len, i, c = 0;
    float s = 0, n = 0;
    string str;

    ifstream infile;
    infile.open("text.in");
    ofstream outfile;
    outfile.open("text.out");

    getline(infile, str);

    len = str.length();
    for (i = 0; i <= len; i += 1) {
        if (i == len) {
            s += c;
            c = 0;
            n +=1;
        }
        if (isalpha(str[i])) {
            c += 1;
        }
        else if (!(isalpha(str[i]))) {
            s += c;
            c = 0;
            n += 1;
        }
    }

    cout << s / n;

    return 0;
}