Pagini recente » Istoria paginii problema/muchiipermutate | Cod sursa (job #2562241) | Cod sursa (job #2325084) | Cod sursa (job #1826625) | Cod sursa (job #2020327)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char a[1034];
int total, cuvinte;
int read;
FILE *f, *g;
int first = 0;
total = 0;
cuvinte = 0;
f = fopen("text.in", "r");
g = fopen("text.out", "w");
if (NULL == f)
{
return 0;
}
if (NULL == g)
{
return 0;
}
do
{
read = fread(a, sizeof(char), 1024, f);
a[read] = 0;
for (int i = 0; i < (int)strlen(a); i++)
{
a[i] = a[i] | 0x20;
if (a[i] >= 'a' && a[i] <= 'z')
{
total++;
first = 1;
}
else
{
if (first)
{
cuvinte++;
first = 0;
}
}
}
} while (read > 0);
if (cuvinte == 0)
return 0;
fprintf(g, "%d", (int)total / cuvinte);
fclose(f);
fclose(g);
return 0;
}