Cod sursa(job #789265)
Utilizator | Data | 17 septembrie 2012 18:34:47 | |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <cstdio>
#include <cstring>
using namespace std;
FILE *f = fopen ("text.in","r");
FILE *g = fopen ("text.out","w");
int main()
{
int lgword, cnt, aux = 0;
char c;
lgword = cnt = 0;
do {
c = getc(f);
if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') )
lgword++, aux++;
else {
if (aux)
cnt++;
aux = 0;
}
} while (c != EOF);
if (cnt)
fprintf (g, "%d\n", lgword / cnt);
else
fprintf (g, "0\n");
fclose(f);
fclose(g);
return 0;
}