Cod sursa(job #1469405)

Utilizator FairPlay94George Cioroiu FairPlay94 Data 8 august 2015 10:47:56
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <climits>
#include <list>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <map>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    freopen("text.in", "r", stdin);
    freopen("text.out", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string text;
    getline(cin, text);
    int litere = 0, numarCuvinte = 0;
    for (int i = 0; i < text.length(); i++) {
        if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z')) {
            numarCuvinte++;
            for ( ; i < text.length() && ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z')); i++)
                litere++;
            i--;
        }
    }
    cout << litere / numarCuvinte;

    return 0;
}