#include #include #include #include #include #include int main() { std::ifstream ifs { "pile.txt" }; std::vector pile { std::istream_iterator{ ifs }, std::istream_iterator{ } }; auto it = std::stable_partition(std::begin(pile), std::end(pile), [](std::string const& note) { return note.ends_with("SEK"); }); double total_cost { std::inner_product(std::begin(pile), it, it, 0.0, std::plus{}, [](std::string const& a, std::string const& b) { double lhs { std::stod(a) }; double rhs { std::stod(b) }; return lhs * rhs; }) }; std::cout << "The total income was: " << total_cost << "SEK" << std::endl; }