Cod sursa(job #1092461)

Utilizator Breje_RaulRaul Breje Breje_Raul Data 27 ianuarie 2014 03:25:38
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <iostream>
#include <fstream>

using namespace std;

#define dimen 100001

int n,nr,noword,noletters=0;
string s;

int main(){
    //#ifndef ONLINE_JUDGE
    //    freopen("test.in", "r", stdin);
        //freopen("test.out", "w", stdout);
    //#endif

    ifstream f("text.in");
    ofstream g("text.out");
    getline(f, s);
    s+=' ';
    //cout << s << "\n";
    for (int i=0;i<s.size();++i){
        if ( (s[i] < 'a' or s[i] > 'z') && (s[i] < 'A' or s[i] > 'Z') && (i > 0) &&
            ( (s[i-1]>='a' and s[i-1]<='z') or (s[i-1]>='A' and s[i-1]<='Z') ) ) ++noword;
        if ( (s[i]>='a' and s[i]<='z') or (s[i]>='A' and s[i]<='Z') ){
            noletters++;
        }
    }
    //cout << noletters << " " << noword;
    g << noletters / noword;
}