<commit_before>//! @<NAME>
//!
//! Exercise 9.50:
//! Write a program to process a vector<string>s whose elements represent
//! integral values.
//! Produce the sum of all the elements in that vector.
//! Change the program so that it sums of strings that represent floating-point
//! values.
//!

#include <iostream>
#include <string>
#include <vector>

int sum_for_int(const std::vector<std::string> &v)
{
    int sum = 0;
    for (auto const& s : v) sum += std::stoi(s);
    return sum;
}

float sum_for_float(const std::vector<std::string> &v)
{
    float sum = 0.0;
    for (auto const& s : v) sum += std::stof(s);
    return sum;
}

int main()
{
    std::vector<std::string> v = {"1", "2", "3", "4.5"};
    std::cout << sum_for_int(v) << std::endl;
    std::cout << sum_for_float(v) << std::endl;

    return 0;
}<commit_msg>Update ex9_50.cpp<commit_after>//! @<NAME>
//!
//! Exercise 9.50:
//! Write a program to process a vector<string> whose elements represent integral values.
//! Produce the sum of all the elements in that vector.
//! Change the program so that it sums of strings that represent floating-point values.
//!

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int sum_for_int(const vector<string> &svec)
{
    int sum=0;
    for(const auto &s : svec)
        sum+=stoi(s);
    return sum;

}

float sum_for_float(const vector<string> &svec)
{
    float sum=0.0;
    for(const auto &s:svec)
        sum+=stof(s);
    return sum;
}

int main()
{
    vector<string> svec{"1", "2", "3", "4.5"};
    cout<<sum_for_int(svec)<<endl;
    cout<<sum_for_float(svec)<<endl;
}
{'fraction_non_alphanumeric': 0.1668726823238566, 'fraction_numerical': 0.016069221260815822, 'mean_word_length': 3.472375690607735, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3047030', 'n_tokens_mistral': 606, 'n_tokens_neox': 573, 'n_words': 176}