Cod sursa(job #1506230)

Utilizator AkerToropu Alexandru Aker Data 20 octombrie 2015 10:58:26
Problema Text Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int word=0,c=0,k=0;  //word = nr de cuv, ch= nr de litere
    char ch;
    FILE *f = fopen("text.in","r");
    FILE *g = fopen("text.out","w");


    while(fscanf(f,"%c",&ch)!=EOF){
        if((ch >='a' && ch <='z') || (ch >='A' && ch <='Z')){
            c++;
            if(k==0){
                word++;
                k = 1;
            }
        }
        else{
                k=0;
            }


    }


    k = c/(word);

    fprintf(g,"%d",k);
    return 0;
}