Cod sursa(job #1780255)

Utilizator tiberiu.bucur17Tiberiu Constantin Emanoil Bucur tiberiu.bucur17 Data 15 octombrie 2016 22:48:59
Problema Text Scor 80
Compilator c Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <stdio.h>
#include <ctype.h>
#define BUF_SIZE 131072
FILE *fin,*fout;
char buf[BUF_SIZE];
int pos=BUF_SIZE,lung,co;
inline char getch()
{
    if(pos==BUF_SIZE)
        fread(buf,BUF_SIZE,1,fin),pos=0;
    return buf[pos++];
}
int main()
{
    fin=fopen("text.in","r");
    fout=fopen("text.out","w");
    char ch=getch();
    while(!iscntrl(ch) || ch=='\n')
    {
        while(!isalpha(ch) && (!iscntrl(ch) || ch=='\n'))
            ch=getch();
        if(isalpha(ch))
        {
            co++;
            do
            {
                lung++;
                ch=getch();
            } while(isalpha(ch));
        }
    }
    fprintf(fout,"%d",lung/co);
    fclose(fin);
    fclose(fout);
    return 0;
}