Cod sursa(job #1577637)

Utilizator TudorVersoiuVersoiu Tudor Sorin TudorVersoiu Data 23 ianuarie 2016 17:12:10
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <iostream>
#include <fstream>
#include <cstring>

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

char text[1000031];

int NrTotalLitere, NrLit, NrCuvinte;


int main()
{
    f.getline(text,1000031); text[strlen(text)] = ' ';

    for ( int i=0 ; text[i] ; i++ )
    {
        if ( !( ('a'<=text[i] && text[i]<='z') or ('A'<=text[i] && text[i]<='Z') ) )
        {
            if ( NrLit ) {
                NrTotalLitere += NrLit;
                NrLit = 0; NrCuvinte++;
            }
        } else NrLit++;
    }
    g << NrTotalLitere/NrCuvinte;
}