Pagini recente » Cod sursa (job #171343) | Cod sursa (job #2147068) | Cod sursa (job #1263129) | Istoria paginii runda/training-1/clasament | Cod sursa (job #481131)
Cod sursa(job #481131)
#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;
}