Pagini recente » Cod sursa (job #2943385) | Cod sursa (job #536969) | Cod sursa (job #1556267) | Cod sursa (job #83787) | Cod sursa (job #2810829)
#include <bits/stdc++.h>
#define MAX_SZ 1000000
using namespace std;
ofstream fout("text.out");
bool esteAlfabet(char n)
{
return (n >= 'a' && n <= 'z') || (n >= 'A' && n <= 'Z');
}
int main()
{
FILE *input = fopen("text.in", "r"), *output = fopen("text.out", "w");
int sz, litere = 0, cuvinte = 0;
char text[MAX_SZ];
//citirea
fseek(input, 0L, SEEK_END);
sz = (int)ftell(input);
rewind(input);
fread(text, sizeof(char), sz, input);
for (int i = 0; i < sz; i++)
{
while (!esteAlfabet(text[i]))
i++;
cuvinte++;
while (esteAlfabet(text[i]))
{
litere++;
i++;
}
}
fprintf(output, "%d", litere / cuvinte);
return 0;
}