Cod sursa(job #2551323)

Utilizator matthriscuMatt . matthriscu Data 19 februarie 2020 19:09:49
Problema Text Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>
#include <cstring>
using namespace std;

char s[1000000], d[127], *p;
int n, w;

int main() {
    ifstream fin("text.in");
    fin.get(s, 10000);
    fin.close();

    int l = strlen(s);
    for(int i = 0; i < l; ++i)
        if(((s[i] >= 'a') && (s[i] <= 'z')) || ((s[i] >= 'A') && (s[i] <= 'Z')))
            n++;

    p = strtok(s, ",-");
    while(p) {
        p = strtok(NULL, ",- ");
        w++;
    }

    ofstream fout("text.out");
    fout << n/w;
    fout.close();
}