Cod sursa(job #286536)

Utilizator firewizardLucian Dobre firewizard Data 23 martie 2009 21:32:16
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>  
#define cuv(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')?1:0)   
char c[2048*1024];   
int main()   
{   
    long n, nc = 0, nl = 0, i;   
    int fd = open("text.in",O_RDONLY);
    n = read(fd, c, sizeof(c));
    c[n]=' ';   
    for (i = 0; i < n; i++){   
        if (cuv(c[i])){   
           nl++;   
           if(!cuv(c[i+1]))nc++;   
           }   
        }   
       
    /*printf("%ld\n%ld\n%ld\n%ld\n",n,nl,nc,(long)(nl/nc));*/  
    freopen("text.out", "w", stdout);
    printf("%ld\n",(long)(nl/nc));  
    return 0;   
}