Pagini recente » Cod sursa (job #1679062) | Cod sursa (job #1694697) | Stapanu tau | Cod sursa (job #1353441) | Cod sursa (job #1234278)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
bool is_letter(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }
int main()
{
char c;
bool k = false;
int words = 0, letters = 0;
FILE* in = fopen("text.in", "r");
FILE* out = fopen("text.out", "w");
while (c = fgetc(in))
{
if (feof(in))
{
break;
}
if (is_letter(c))
{
letters++;
if (k == false){
words++;
k = true;
}
}
else k = false;
}
fprintf(out,"%d", letters / words);
fclose(out);
return 0;
}