Cod sursa(job #1603595)

Utilizator NecoaraGabrielNecoara Gabriel-Stefan NecoaraGabriel Data 17 februarie 2016 17:57:19
Problema Text Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb

//http://www.infoarena.ro/problema/text

#include<iostream>
#include<fstream>
#include<string.h>
using namespace  std;

char x[10000];
long unsigned lit=0,nrCuv=-1;


void check(char a[],long unsigned &lit,long unsigned &nrCuv)
{
    int i;
    for(i=0;i<strlen(a);i++)
       {
           lit++;

           if(a[i]==' ' || a[i]=='-' )
            nrCuv++;
            if(a[i]==','||a[i]=='!')
                lit--;
            //puts(a);
            //cout<<" Litere= "<<lit<<" "<<"Cuvinte= "<<nrCuv<<endl;
       }
}
int main(){

ifstream f("text.in");
ofstream g("text.out");

while(!f.eof())
{

     nrCuv++;
    f>>x;
    if(x[0]=='-')
    {
       //puts(x);
       //cout<<" ";
        nrCuv--;
    }

   check(x,lit,nrCuv);
}

g<<lit/nrCuv;

}