Cod sursa(job #1702781)

Utilizator borscalinCalin-Stefan Georgescu borscalin Data 15 mai 2016 15:52:30
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <cstdio>
#include <cstring>

using namespace std;

inline bool my_isalpha(char x){
    if ((x >= 'A' && x <= 'Z') || (x >= 'a' && x <= 'z'))
        return 1;
    return 0;
}

int main(){
    FILE *fin, *fout;
    int i,cuv = 0,litere = 0,ok = 0;
    char ch;
    fin = fopen("text.in","r");
    while (fscanf(fin,"%c",&ch) != EOF){
        if (my_isalpha(ch) == 1){
            litere++;
            ok = 1;
        }
        else if (ok == 1){
            cuv++;
            ok = 0;
        }
    }
    fclose(fin);
    fout = fopen("text.out","w");
    fprintf(fout,"%d",litere / cuv);
    fclose(fout);
    return 0;
}