Cod sursa(job #496168)

Utilizator krityxAdrian Buzea krityx Data 27 octombrie 2010 22:02:34
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include<string>
#include<fstream>
#include<cctype>

using namespace std;

int main()
{
    ifstream f("text.in");
    ofstream g("text.out");
    char txt[1000],txt2[1000],*p;
        long nr=0,k=0;


    f.getline(txt,1000);
    strcpy(txt2,txt);
    p=strtok(txt," .,;");
    while(p!=NULL)
    {
        k++;
        p=strtok(NULL," .,;");
    }
   //p=strtok(txt2," .,;-!?_'=)(~/@*#$%^&");
    /*while(p!=NULL)
    {
        nr+=strlen(p);
        p=strtok(NULL, " .,;-!?_'=)(~/@*#$%^&");
    }*/

    for(int i=0;i<=strlen(txt2);i++)
    if(isalpha(txt[i])) nr++;
    g<<nr/k;
    f.close();
    g.close();
}