-
-
Save Dobiasd/a4e7aa9c25a3dd4c0522d75a71e2a867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iterator> | |
#include <vector> | |
struct cat | |
{ | |
double cuteness() const | |
{ | |
return softness_ * temperature_ * roundness_ * fur_amount_ - size_; | |
} | |
std::string name_; | |
double softness_; | |
double temperature_; | |
double size_; | |
double roundness_; | |
double fur_amount_; | |
}; | |
int main() | |
{ | |
std::vector<cat> cats = { | |
{"Tigger", 5, 5, 5, 5, 5}, | |
{"Simba", 2, 9, 9, 2, 7}, | |
{"Muffin", 9, 4, 2, 8, 6}, | |
{"Garfield", 6, 5, 7, 9, 5}}; | |
auto best_it = std::end(cats); | |
double best_cuteness = 0.0; | |
for (auto it = std::begin(cats); it != std::end(cats); ++it) | |
{ | |
auto it_cuteness = it->cuteness(); | |
if (it_cuteness > best_cuteness) | |
{ | |
best_cuteness = it_cuteness; | |
best_it = it; | |
} | |
} | |
std::cout << best_it->name_ << | |
" is happy and sleepy. *purr* *purr* *purr*" << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:) nice, thanks