Cod sursa(job #45056)
Utilizator | Popa Marius Ionut mariaci | Data | 31 martie 2007 23:19:38 |
---|---|---|---|
Problema | Text | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<stdio.h>
#include<string.h>
char a[10000];
int main()
{ FILE *f=fopen("text.in","r");
fgets(a,10000,f);
long s=0,c=0;
char *p;
p=strtok(a,"-,.;@#$%^&*():?! ");
if(p)
{ s=s+strlen(p);
c++;
}
while(p)
{ p=strtok(NULL,"-,.;@#$%^&*() :?!");
if(p)
{ s=s+strlen(p);
c++;
}
}
FILE *g=fopen("text.out","w");
fprintf(g,"%d",s/c);
fclose(f);
fclose(g);
return 0;
}