Cod sursa(job #1227985)

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

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

char text[10030];

int main()
{
    int iNrChar=0, iNrWords=0;

    f.getline(text,10030);

    for(int i=0; i<strlen(text); i++)

        if(isalpha(text[i])) {
            ++iNrChar;
            if(i == 0)
               ++iNrWords;
            else if(!isalpha(text[i-1]))
               ++iNrWords;

    }
    g<<iNrChar/iNrWords;


    return 0;
}