Cod sursa(job #1535410)

Utilizator BogdanVMVilculescu Mihai Bogdan BogdanVM Data 24 noiembrie 2015 19:01:26
Problema Text Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

char text[1000];

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

int main()
{
   char simb[] = ",.?!-;:+=\"'";
   int i=0,nr=0,nr_cuv=0;
   cout<<simb;
   while(!f.eof())
   {
       f.get(text[i]);
       if (strchr(simb,text[i])) {i++; continue;}
       else if (text[i] != ' '){
         int nr_lit = 0; nr_cuv++;
         while(!strchr(simb,text[i]) && text[i] != ' ')
         {

             nr_lit++;
             i++;
             f.get(text[i]);
         }
         nr+=nr_lit;
         i++;
       }
   }

   g<<(int)(nr/nr_cuv)<<'\n';

   f.close();
   g.close();
}