Cod sursa(job #915862)

Utilizator tipitzaCarausu Ioana tipitza Data 15 martie 2013 13:59:36
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <iostream>
#include<fstream>
#include<string.h>
using namespace std;

int main()
{
    ifstream f;
    ofstream g;
    f.open("text.in");
    g.open("text.out");
    char s[256], *p, e[]=" ,.!?;:(){}[]/\-""!\@#$%^&*_+<>|'`~1234567890";
    int i,n=0,c=0;
    float k;
    f.get(s,256);
    i=0;
    while(isalpha(s[i])==0)
        i++;
    strcpy(s,s+i);
    p=strtok(s,e);
    while(p)
    {
        c++;
        n+=strlen(p);
        p=strtok(NULL, e);
    }
    k=(float)n/(float)c;
    if(strlen(s)==0)
        g<<"0";
    else
        g<<(int)k;
    return 0;
}