#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
struct element_type
{
double value;
std::string strings[2];
};
std::vector<element_type> elements =
{
{ 100.0, { "aaaaaaaaaaaa", "bbbbbbbbbbbb" } },
{ 200.0, { "cccccccccccc", "dddddddddddd" } },
{ 300.0, { "eeeeeeeeeeee", "ffffffffffff" } },
{ 400.0, { "hhhhhhhhhhhh", "gggggggggggg" } }
};
std::ostream& operator<<(std::ostream& os, const element_type& e)
{
os << std::fixed << std::setprecision(2) << e.value << ' '
<< e.strings[0] << ' ' << e.strings[1];
return os;
}
template <typename container_type>
void display(std::ostream& os, const container_type& container)
{
for (unsigned i = 0; i < container.size(); ++i)
os << i << ' ' << container[i] << '\n';
os << '\n';
}
int main()
{
display(std::cout, elements);
unsigned index;
std::cout << "Enter element you'd like to remove.\n> ";
if (std::cin >> index && index < elements.size())
{
std::cout << "Removing element " << index << ".\n";
elements.erase(elements.begin() + index);
display(std::cout, elements);
}
else
std::cout << "Unable to remove element " << index << ".\n";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KCnN0cnVjdCBlbGVtZW50X3R5cGUKewogICAgZG91YmxlIHZhbHVlOwogICAgc3RkOjpzdHJpbmcgc3RyaW5nc1syXTsKfTsKCnN0ZDo6dmVjdG9yPGVsZW1lbnRfdHlwZT4gZWxlbWVudHMgPQp7CiAgICB7IDEwMC4wLCB7ICJhYWFhYWFhYWFhYWEiLCAiYmJiYmJiYmJiYmJiIiB9IH0sCiAgICB7IDIwMC4wLCB7ICJjY2NjY2NjY2NjY2MiLCAiZGRkZGRkZGRkZGRkIiB9IH0sCiAgICB7IDMwMC4wLCB7ICJlZWVlZWVlZWVlZWUiLCAiZmZmZmZmZmZmZmZmIiB9IH0sCiAgICB7IDQwMC4wLCB7ICJoaGhoaGhoaGhoaGgiLCAiZ2dnZ2dnZ2dnZ2dnIiB9IH0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