Cod sursa(job #1493369)

Utilizator Firealex2Rotileanu Alexandru Firealex2 Data 29 septembrie 2015 09:41:01
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <iostream>
#include <string>
#include <fstream>

using namespace std;
ifstream fi("text.in");
ofstream fo("text.out");
int main()
{
    int i, gasit = 0, ltotal=0, nrcuvinte=0;
    char a;
    string text;
    getline(fi,text);
    for(i=1;i<text.length();i++)//65-90 + 97-122
    {
        a = text.at(i);
       if((text.at(i)>=65)&&(text.at(i)<=122))
        {
            ltotal++;
            gasit = 1;
        }
        else if(((text.at(i) == ' ')||(text.at(i)== '-'))&&(gasit==1))
            {
                nrcuvinte++;
                gasit = 0;
            }
        if(((text.at(i)=='.')||(text.at(i)=='!')||(text.at(i)=='?'))&&(gasit==1))
            nrcuvinte++;
    }
    fo<<ltotal/nrcuvinte;
    return 0;
}