Cod sursa(job #2211994)

Utilizator vladuandreeaVladu Andreea Teodora vladuandreea Data 12 iunie 2018 18:44:36
Problema Text Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <fstream>

using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");

int main()
{
    char ch,ch2;
    int cnt=0,ok=0,lit=0;
    while(fin>>ch)
    {

              // fout<<"spatiu "<<ok<<endl;
        if(ch>='a' && ch<='z' || ch>='A' && ch<='Z')
        {
            ok++;
            lit++;


        }
        else
        {

            if(ok>0)
              if(ok>0)
                {cnt++;


                }
            ok=0;   {cnt++;


                }
            ok=0;
        }
        if (fin.peek() == ' ' )
        {
             if(ok>0)
                {cnt++;


                }
            ok=0;
        }
        ch2=ch;
    }
    if(ch2>='a' && ch2<='z' || ch2>='A' && ch2<='Z')
        cnt++;

    if(cnt!=0)
        fout<<lit/cnt;
    else
        fout<<0;
    return 0;
}