Cod sursa(job #3040071)

Utilizator amcbnCiobanu Andrei Mihai amcbn Data 29 martie 2023 12:04:44
Problema Text Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
/// [A][M][C][B][N] ///
#include <bits/stdc++.h>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");

bool ok(char c) {
	return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	char c;
	int curr = 0, cnt = 0, len = 0;
	while (fin >> c) {
		if (ok(c)) {
			curr++;
		}
		else {
			if (curr) {
				len += curr, cnt++;
			}
			curr = 0;
		}
	}
	if (curr) {
		len += curr, cnt++;
	}
	fout << len / cnt;
}