#include #include // Simple stl-task // Tell me if this boardgame collection is optimal // Optimal means that the fun devided by difficulty of storage is greater or equal to 3 // If optimal say its optimal // If not, tell me which are not optimal (loop ok for printing) using namespace std; struct Game { string name; int fun; int storage; }; //Part of solution bool is_not_optimal(Game const& game) { //cout << game.name << ": " << game.fun/game.storage << endl; return game.fun/game.storage < 3; } int main() { vector games{ Game{"Root", 10, 3}, Game{"Twilight Imperium", 8, 2}, Game{"Descent Journeys in the Dark: second edition", 9, 3}, Game{"Descent Journeys in the Dark: first edition", 8, 5}, Game{"Arcs", 7, 3} }; //Part of solution vector unoptimal_games{}; std::copy_if(games.begin(), games.end(), std::back_inserter(unoptimal_games), is_not_optimal); for (Game const& game : unoptimal_games) { std::cout << game.name << std::endl; } }