Cod sursa(job #1586722)

Utilizator geo_furduifurdui geo geo_furdui Data 1 februarie 2016 16:50:01
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
FILE *f, *g;
char s[10000000];
int NrCuv, NrLit;
 
bool EsteLitera (char c) {
    if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
        return true;
    return false;
}
 
int main() {
 
    f = fopen("text.in", "r");
    g = fopen("text.out", "w");
 
    fscanf(f, "%s", &s);
 
    while (!feof(f))
    {
        for (int i = 0; s[i] != NULL; i++)
        {
            if (EsteLitera(s[i]))
            {
                NrLit++;
                if (!EsteLitera(s[i-1]) || i == 0) NrCuv++;
            }
        }
        fscanf(f, "%s", &s);
    }
 
 
    fprintf(g, "%d", NrLit/NrCuv);
 
    fclose(f);
    fclose(g);
 
    return 0;
}