Pagini recente » Cod sursa (job #1268708) | Cod sursa (job #571094) | Cod sursa (job #46732) | Cod sursa (job #2517571) | Cod sursa (job #11020)
Cod sursa(job #11020)
#include<fstream.h>
#include<string.h>
#include<ctype.h>
void main()
{
fstream f("text.in",ios::in);
fstream g("text.out",ios::out);
char s[1000000],sep[]=" -",*p,c,nrc=0,aux[1000000];
int i,nr=0,nr2=0;
while(f>>c)
{
f.get(s,1000000);
strcpy(aux,s);
s[0]=c;
strcpy(s+1,aux);
for(i=0;i<strlen(s);i++)
if(ispunct(s[i])&&s[i]!='-')
strcpy(s+i,s+i+1);
p=strtok(s,sep);
while(p)
{
nr+=strlen(p);
strcpy(p,p+strlen(p));
p=strtok(NULL,sep);
nr2++;
}
}
g<<nr/(nr2-1)<<endl;
f.close();
g.close();
}