Cod sursa(job #1411344)

Utilizator LilithhCondurachi Georgiana Lilithh Data 31 martie 2015 17:17:04
Problema Text Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
# include <fstream>
# include <string.h>

using namespace std;

int main ()
{
    char t[1001];
    unsigned lit=0,cuv=0;
    ifstream fin ("text.in");
    ofstream fout("text.out");

    while(fin.get(t,1001))
    {
        for(int i = 0; i < strlen(t); i++)
       {if((t[0] >= 'a' && t[0]<='z')||(t[0]>='A'&&t[0]<='Z'))
           {if((t[i] >= 'a' && t[i]<='z')||(t[i]>='A'&&t[i]<='Z'))
        lit++;
            if(t[i+1]>=' '&& t[i+1]<='@'&& (t[i] >= 'a' && t[i]<='z'))
        cuv++;
        }
        else
           {if((t[i] >= 'a' && t[i]<='z')||(t[i]>='A'&&t[i]<='Z'))
        lit++;
            if(t[i]>=' '&& t[i]<='@'&& (t[i+1] >= 'a' && t[i+1]<='z'))
        cuv++;
        }

    }}
    if(cuv==0)
    fout<<0;
 else
   fout<<lit/cuv;
   fin.close();
   fout.close();
    return 0;
}