Cod sursa(job #186369)

Utilizator firewizardLucian Dobre firewizard Data 27 aprilie 2008 20:10:00
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <stdio.h>
#include <string>
#include <io.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys\stat.h>
#define LIT(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) 
char buf[2048*1024]; 
int main() 
{ 
    int n, nc = 0, nl = 0, i; 
    int fd = open("text.in", O_RDONLY); 
    n = read(fd, buf, sizeof(buf)); 
    buf[n] = ' '; 
    for (i = 0; i < n; i++){ 
        if (LIT(buf[i])){ 
           nl++; 
           if (!LIT(buf[i+1]))
              nc++; 
           } 
        } 
    freopen("text.out", "w", stdout);
    printf("%d\n", nl/nc); 
    return 0; 
}