Cod sursa(job #2020884)

Utilizator RobertLISARURobert Lisaru RobertLISARU Data 11 septembrie 2017 21:58:26
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <fstream>
#include <string.h>

using namespace std;

int main()
{
    ifstream fin("text.in");
    ofstream fout("text.out");

    unsigned nrCuvinte = 0;
    unsigned nrLitere = 0;

    char bucata[1048576];
    unsigned lungimeBucata;
    bool hasLetter;

    while(fin>>bucata){
        lungimeBucata = strlen(bucata);
        hasLetter = false;
        for(int i = 0; i<lungimeBucata; i++){
            if((bucata[i]<='z'&&bucata[i]>='a') || (bucata[i]<='Z'&&bucata[i]>='A')){
                nrLitere++;
                hasLetter = true;
            }
            else if(hasLetter){
                nrCuvinte++;
                hasLetter = false;
            }
        }
        if(hasLetter) nrCuvinte++;
    }

    fout<<nrLitere/nrCuvinte;

    fin.close();
    fout.close();

    return 0;
}