Cod sursa(job #1227993)

Utilizator twinkey_gunnerMuresan Gabi twinkey_gunner Data 12 septembrie 2014 14:18:28
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>
#include <string.h>
#include <assert.h>
using namespace std;

ifstream f("text.in");
ofstream g("text.out");

char text, dinainte;

int main()
{
    int iNrChar=0, iNrWords=0;
    dinainte = '#';
    int cnt = 0;
    while(f.get(text)) {
        ++ cnt;
        assert(cnt <= 10005);
        if(isalpha(text)) {
            ++iNrChar;
            if(!isalpha(dinainte))
               ++iNrWords;
        }
        dinainte = text;
    }
    g<<iNrChar/iNrWords;


    return 0;
}