Cod sursa(job #2774295)

Utilizator amcbnCiobanu Andrei Mihai amcbn Data 10 septembrie 2021 22:02:45
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
/* [A][M][C][B][N] / [K][R][I][P][6][8] */
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
// Global variables
const char sp = ' ', nl = '\n';
const int MOD = 777013; // 666013 998244353 1000000007
ifstream fin("text.in");
ofstream fout("text.out");

int main() {
    string str;
    getline(fin, str);
    for (int i = 0; i < str.size(); i++)
        if (!isalnum(str[i]))
            str[i] = ' ';
    int len(0), w(0);
    string word = "";
    for (auto x : str) {
        if (x == ' ') {
            if (word.size())
                w++, len += word.size();
            word = "";
        }
        else word += x;
    }
    if (word.size())
        w++, len += word.size();
    fout << len / w;
}