Cod sursa(job #1557803)

Utilizator Belu99Bibo Bela Belu99 Data 28 decembrie 2015 12:22:21
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <iostream>
#include <fstream>
using namespace std;
int x=0,y=0,n,i,k=0;
string s;
int main()
{
    ifstream f("text.in");
    ofstream g("text.out");
    while(!f.eof())
    {
        getline(f,s);
        n=s.size();
        k=0;
        for(i=0;i<n;i++)
        {
            if((s[i]>='A' and s[i]<='Z') or (s[i]>='a' and s[i]<='z'))
                {
                    x++;
                    if(k==0)
                    {
                        y++;
                        k=1;
                    }
                }
            else
                {
                    k=0;
                    while(s[i]<'A' or (s[i]>'Z' and s[i]<'a') or s[i]>'z')
                      i++;
                    i--;
                }
        }
        s.erase(0,n-1);
    }
    g<<x/y;
    return 0;
}