Cod sursa(job #1227983)

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

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

char text[1030];

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

    f.getline(text,2030);

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

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

    }

    g<<iNrChar/iNrWords;


    return 0;
}