Pagini recente » Cod sursa (job #2865993) | Cod sursa (job #2705970) | Cod sursa (job #1839620) | Cod sursa (job #2031064) | Cod sursa (job #2758314)
#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)) && ((int)text[i]==10 || ((int)text[i]>=32 && (int)text[i]<=47)||((int)text[i]>=58 &&(int)text[i]<=63)||((int)text[i]>=91 && (int)text[i]<=96)||((int)text[i]>=123 && (int)text[i]<=126)))
{
c++;
}
}
return c;
}
int main()
{
char text[100000];
FILE *f=fopen("text.in","r"),*g=fopen("text.out","w");
fgets(text,1000,f);
fprintf(g,"%i",calculare_litere(text)/calculare_cuvinte(text));
fclose(f);
fclose(g);
return 0;
}