Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <map>
- #include <functional>
- bool compare(Figure *left, Figure *right) {
- return left->get_square() < right->get_square();
- }
- int main() {
- std::vector<Figure*> figures;
- std::map<std::string, std::function<Figure *(std::string)>> plant =
- {
- {"R", Rectangle::make},
- {"C", Circle::make},
- {"S", Square::make}
- };
- std::string type;
- while (std::cin >> type) {
- std::string param;
- std::getline(std::cin, param);
- figures.push_back(plant[type](param));
- }
- std::stable_sort(figures.begin(), figures.end(), compare);
- for (auto it : figures) {
- std::cout << it->to_string() << std::endl;
- delete it;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement