Cod sursa(job #1332660)

Utilizator FapFapAdriana FapFap Data 2 februarie 2015 11:45:01
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

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

string s;

int main(){
    int total=0, words=0;
    bool ok;
    getline (fin, s);
    for(int i=1; i<s.size(); i++){
        if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z'))
            total++, ok=true;
        else if(ok && ((s[i-1]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z')))
            words++, ok=false;
    }
    fout << total/words;
    return 0;
}