Cod sursa(job #1312190)
| Utilizator | Data | 8 ianuarie 2015 23:22:02 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <stdio.h>
#include <string.h>
int isletter(char a)
{
if( ('a'<=a && a<='z') || ('A'<=a && a<='Z'))
return 1;
return 0;
}
int main()
{
long int letter=0,word=0;
int start=0;
char c;
FILE *in = fopen("text.in","r");
freopen("text.out","w",stdout);
c = getc(in);
while(c!=EOF)
{
if(isletter(c))
{
letter++;
if(!start)
{
word++;
}
start = 1;
}
else
start = 0;
c = getc(in);
}
if(word)
printf("%ld\n",letter/word);
else
printf("%d\n",0);
fclose(in);
return 0;
}