Pagini recente » Cod sursa (job #639439) | Cod sursa (job #2412414) | Cod sursa (job #2835268) | Cod sursa (job #1679660) | Cod sursa (job #834792)
Cod sursa(job #834792)
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char text[2000000],text1[200000];
int main()
{
int i;
FILE *f=fopen("text.in","r");
while(!feof(f))
{fgets(text1,20000,f);
strcat(text,text1);}
int nrchr=0;
for(i=0;i<=strlen(text)-1;i++)
if(!isalpha(text[i]))
text[i]=' ';
else
nrchr++;
if(text[0]==' ')
while(text[0]==' ')
strcpy(text,text+1);
char *p;
p=text;
int ncuv=0;
for(p=strtok(text," ");p;p=strtok(NULL," "))
ncuv++;
fclose(f);
f=fopen("text.out","w");
fprintf(f,"%d",nrchr/ncuv);
return 0;
}