Cod sursa(job #532833)

Utilizator bogdanvilceleanuBogdan Vilceleanu bogdanvilceleanu Data 12 februarie 2011 16:20:19
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<cstdio>
#include<cstring>
using namespace std;
char c[10005],mat[10005][10005],*p,sep[]=" -,.!?";
int main()
{
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
    long i,n=0,s=0;
    gets(c);
    p=strtok(c,sep);
    while(p)
    {
        strcpy(mat[++n],p);
        p=strtok(NULL,sep);
    }
    for(i=1;i<=n;i++)
        s+=strlen(mat[i]);
    printf("%ld",s/n);
    return 0;
}