Cod sursa(job #481131)
| Utilizator | Data | 30 august 2010 18:24:07 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <stdio.h>
#include <ctype.h>
using namespace std;
char ch;
int lung, cuvinte, i;
int is_letter (char x)
{
if (tolower (x) >= 'a' && tolower (x) <= 'z')
return 1;
return 0;
}
int main ()
{
FILE *f = fopen ("text.in","r");
FILE *g = fopen ("text.out","w");
while (fscanf (f,"%c", &ch) != EOF)
{
if (is_letter (ch))
{
lung ++;
if (!i)
cuvinte ++;
i = 1;
}
else
i = 0;
}
//printf ("%d", cuvinte);
fprintf (g, "%d\n", lung / cuvinte);
fclose (g);
fclose (f);
return 0;
}
