Cod sursa(job #2774829)

Utilizator Gabryel9898Bizdoc Vasile Gabriel Gabryel9898 Data 13 septembrie 2021 02:42:48
Problema Text Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.06 kb
#include <iostream>
#include <chrono>
#include <fstream>
#include <string>

std::ifstream in;
std::ofstream out;


int is_letter(char t) {
    return (t >= 'a' && t <= 'z') ||    (t >= 'A' && t <= 'Z');
}

int is_space(char t) {
    return t == ' ';
}

void solve() {
    in.open("../text.in");
    out.open("../text.out");

    std::string input_string;
    std::getline(in, input_string);

    int white_spaces = 1;
    int letters = 0;

    for (auto t: input_string) {
        int letter_count = is_letter(t);
        int space_count = is_space(t);

        letters += letter_count;
        white_spaces += space_count;
    }
    out << letters / white_spaces;
//    out << letters  << " " << white_spaces;
}


int main() {
    auto start = std::chrono::high_resolution_clock::now();

    solve();

    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start);
    std::cout << std::endl << "[time]:" << duration.count() << std::endl;
    return 0;
}