Cod sursa(job #1459235)

Utilizator gamamenMuntean Catalin gamamen Data 9 iulie 2015 14:22:18
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.9 kb
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
ifstream in("text.in");
ofstream out("text.out");

int main() {
    char text[10000];
    in.get(text, 10000);
    int cuvinte = 0, litere = 0;
    bool cuvant = false;
    for (int i = 0; i <= strlen(text); i++) {
        if (cuvant == true) {
            if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'z')) {
                litere++;
            } else {
                cuvant = false;
            }
        } else {
            if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'z')) {
                litere++;
                cuvinte++;
                cuvant = true;
            }
        }
    }
    if (cuvinte > 0 && litere >0) {
        out << litere/cuvinte;
    } else {
        out << 0;
    }
    in.close();
    out.close();
    return 0;
}