Pagini recente » pre_oni_gim2015 | Cod sursa (job #735226) | Cod sursa (job #1708882) | Rating Calin Cojocariu (calincoj) | Cod sursa (job #481121)
Cod sursa(job #481121)
#include <stdio.h>
#include <ctype.h>
using namespace std;
char ch;
int lung, cuvinte;
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 (!feof(f))
{
fscanf (f,"%c", &ch);
if (feof(f))
break;
if (ch == ' ')
cuvinte ++;
else if (is_letter (ch))
lung ++;
}
cuvinte ++;
fprintf (g, "%d\n", lung / cuvinte);
fclose (g);
fclose (f);
return 0;
}