Cod sursa(job #2934422)
| Utilizator | Data | 5 noiembrie 2022 23:23:45 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <bits/stdc++.h>
using namespace std;
bool is_letter(char c) {
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}
int main() {
FILE *in = fopen("text.in", "r"),
*out = fopen("text.out", "w");
const int BUFSIZE = 6e4;
char buf[BUFSIZE];
int words = 0, letters = 0, last = 0;
while (fgets(buf, BUFSIZE, in)) {
for (int i = 0, l = strlen(buf); i < l; ++i) {
if (is_letter(buf[i])) {
++letters;
words += !last;
}
last = is_letter(buf[i]);
}
}
fprintf(out, "%d\n", letters / words);
}