Pagini recente » Istoria paginii utilizator/gudeialina | Monitorul de evaluare | Cod sursa (job #1765979) | Cod sursa (job #2093695) | Cod sursa (job #2453314)
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int is_letter(unsigned char A)
{
if ((A >= 'a' && A <= 'z') || (A >= 'A' && A <= 'Z'))
return 1;
return 0;
}
int main()
{
FILE* f = fopen("text.in", "rt");
unsigned char text[1000000];
unsigned long count = 0, len=0, sum=0;
fgets(text, 1000000, f);
//printf("%s \n", text);
for (int i = 0; text[i]!='\0'; i++)
{
if (is_letter(text[i]))
len++;
else
if (len != 0)
if (len == 1)
len = 0;
else
{
sum = sum + len;
len = 0;
count++;
}
//printf("Letter: %c Count: %u Lenght: %u Total: %u \n", text[i], count, len, sum);
}
sum = sum / count;
f = fopen("text.out", "wt");
fprintf(f, "%lu \n", sum);
fflush(stdout);
fclose(f);
return 0;
}