Pagini recente » Cod sursa (job #2796933) | Cod sursa (job #48182) | Cod sursa (job #696442) | Cod sursa (job #1772323) | Cod sursa (job #789253)
Cod sursa(job #789253)
#include <cstdio>
#include <cstring>
using namespace std;
FILE *f = fopen ("text.in","r");
FILE *g = fopen ("text.out","w");
int n;
char text[1000005];
int main()
{
int lgword, cnt, aux = 0;
fgets (text, 1000005, f);
n = strlen(text);
lgword = cnt = 0;
for (int i = 0; i < n; i++) {
if ( (text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z') )
lgword++, aux++;
else {
if (aux)
cnt++;
aux = 0;
}
}
if (cnt)
fprintf (g, "%d\n", lgword / cnt);
else
fprintf (g, "0\n");
fclose(f);
fclose(g);
return 0;
}