Pagini recente » Cod sursa (job #1991357) | Rating Abi Talent (imparatulVerde) | Cod sursa (job #1548196) | Cod sursa (job #504877) | Cod sursa (job #2011559)
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
typedef unsigned int uint;
int main(void)
{
FILE *in = fopen("text.in", "r");
FILE *out = fopen("text.out", "w");
if(in != NULL && out != NULL)
{
int64_t total_len = 0;
int64_t words = 0;
int64_t current = 0;
char c = 'a';
while(1)
{
c = getc(in);
if(c == EOF || c == -1)
{
break;
}
else
{
if(ispunct(c) || c == ' ')
{
if(current > 0)
{
words++;
current = 0;
}
}
if(isalpha(c) && c != ' ')
{
total_len++;
current++;
}
}
}
fprintf(out, "%lld\n", (int64_t)(total_len / words));
fclose(in);
fclose(out);
}
else
{
printf("Error\n");
}
return 0;
}