Pagini recente » Cod sursa (job #2898067) | Cod sursa (job #1402201) | Cod sursa (job #763557) | Cod sursa (job #1305623) | Cod sursa (job #834788)
Cod sursa(job #834788)
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char text[20000];
int main()
{
int i;
FILE *f=fopen("text.in","r");
fgets(text,20000,f);
if(text[strlen(text)-1]=='\n')
text[strlen(text)-1]=0;
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;
}