Pagini recente » Cod sursa (job #2106251) | Cod sursa (job #2933434) | Cod sursa (job #367648) | Cod sursa (job #1042883) | Cod sursa (job #2758310)
#include <cstdio>
#include<string.h>
using namespace std;
int calculare_litere(char text[])
{
int c=0;
for(int i=0;i<strlen(text);i++)
{
if(((int)text[i]>=65 && (int)text[i]<=90)||((int)text[i]>=97 && (int)text[i]<=122))
{
c++;
}
}
return c;
}
int calculare_cuvinte(char text[])
{
int c=0;
for(int i=1;i<strlen(text);i++)
{
if((((int)text[i-1]>=65 && (int)text[i-1]<=90)||((int)text[i-1]>=97 && (int)text[i-1]<=122)||((int)text[i-1]>=48 && (int)text[i-1]<=57))&&(text[i]==' ' || text[i]==',' || text[i]=='.' || text[i]=='?' || text[i]=='!' || text[i]=='-' || text[i]==';' || text[i]==':'))
{
c++;
}
}
return c;
}
int main()
{
char text[100000];
FILE *f=fopen("text.in","r"),*g=fopen("text.out","w");
fgets(text,1000,f);
fclose(f);
fprintf(g,"%i",calculare_litere(text)/calculare_cuvinte(text));
fclose(g);
return 0;
}