Pagini recente » Cod sursa (job #360701) | Cod sursa (job #2643816) | Cod sursa (job #333354) | Cod sursa (job #2434172) | Cod sursa (job #2244393)
#include <stdio.h>
#include <stdlib.h>
int main()
{ char ch;
int numarCuvinte = 0;
int esteCuvant = 0;
int numarLitere = 0;
FILE* f = fopen("text.in", "r");
FILE* g = fopen("text.out", "w");
while ((ch = fgetc(f)) != EOF)
{
if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
{
numarLitere++;
esteCuvant = 1;
}
if (esteCuvant == 1 && (ch < 'A' || ch > 'z'))
{
numarCuvinte++;
esteCuvant = 0;
}
}
if (esteCuvant == 1)
numarCuvinte++;
fprintf(g, "%d", numarLitere / numarCuvinte);
return 0;
}