Cod sursa(job #1322894)

Utilizator thehuntestshadowDragomir Alexandru thehuntestshadow Data 20 ianuarie 2015 14:58:23
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main ()
{
    string s;
    ifstream fin ("text.in");
    fin >> s;
    int c=0;
    int sum=0;
    int elemente =0;
    while (fin >> s)
    {
          c=0;
          for(int i=0;i<s.length();++i){
          
                  if(s[i]>='a'&&s[i]<='z')
                  c++;
                  else if (s[i]>='A'&&s[i]<='Z')
                       c++;
                  else {
                       if(c>0){elemente++;sum+=c;c=0;}
                       else c=0;
                       }
          }
          if(c>0){elemente++;sum+=c;}
          
          
    }
    fin.close();
    ofstream fout ("text.out");
    fout << sum/elemente << "\n";
    fout.close();
    return 0;
    
}