Pagini recente » Cod sursa (job #1560003) | Cod sursa (job #2153584) | Cod sursa (job #2458558) | Rating Teoteoi Tudor-Cristian (t3t3lu) | Cod sursa (job #1259751)
#include<stdio.h>
#include<string.h>
int main()
{
FILE *input, *output;
input = fopen ("text.in", "rt");
output = fopen ("text.out", "wt");
char text[999999];
int i, k;
int ChrCounter = 0;
int WrdCounter = 0;
fgets(text, 999999, input);
for (i=0; i<strlen(text); i++)
{
if ( (text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z') )
{
ChrCounter++;
k=0;
}
if ( !(text[i] >= 'a' && text[i] <= 'z') && !(text[i] >= 'A' && text[i] <= 'Z') )
{
k++;
if (k == 1)
WrdCounter++;
}
}
fprintf(output, "%d" , ChrCounter/WrdCounter);
}