Cod sursa(job #2663684)
| Utilizator | Data | 27 octombrie 2020 00:33:07 | |
|---|---|---|---|
| Problema | Text | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <iostream>
#include <fstream>
#include <string>
bool is_alphabetic(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
int main() {
std::ifstream in("text.in");
std::ofstream out("text.out");
std::string str;
std::getline(in, str);
int words = is_alphabetic(str[0]), len = is_alphabetic(str[0]);
for (int i = 1; i < str.size(); ++i) {
if (is_alphabetic(str[i])) {
len++;
if (!is_alphabetic(str[i - 1]))
++words;
}
}
out << len / words << '\n';
out.close();
return 0;
}
