#include <iostream>
template <typename T>
class MyVector
{
private:
unsigned vtr_size;
unsigned capacity;
T* elements;
public:
MyVector(unsigned size, T default_value = T())
: vtr_size(size), capacity(size), elements(new T[size])
{
for (unsigned i = 0; i < vtr_size; ++i)
elements[i] = default_value;
}
T at(unsigned index) const
{
if ( index < vtr_size)
return elements[index];
return T();
}
unsigned size() const { return vtr_size; }
};
template <typename container>
void print(const container& c)
{
for (unsigned i = 0; i < c.size(); ++i)
std::cout << c.at(i) << ' ';
std::cout << '\n';
}
int main()
{
MyVector<int> V1(5);
MyVector<int> V2(5, 4);
print(V1);
std::cout << '\n';
print(V2);
std::cout << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CmNsYXNzIE15VmVjdG9yCnsKcHJpdmF0ZToKICAgIHVuc2lnbmVkIHZ0cl9zaXplOwogICAgdW5zaWduZWQgY2FwYWNpdHk7CiAgICBUKiBlbGVtZW50czsKCnB1YmxpYzoKICAgIE15VmVjdG9yKHVuc2lnbmVkIHNpemUsIFQgZGVmYXVsdF92YWx1ZSA9IFQoKSkgCiAgICAJOiB2dHJfc2l6ZShzaXplKSwgY2FwYWNpdHkoc2l6ZSksIGVsZW1lbnRzKG5ldyBUW3NpemVdKSAKICAgIHsKICAgICAgICBmb3IgKHVuc2lnbmVkIGkgPSAwOyBpIDwgdnRyX3NpemU7ICsraSkKICAgICAgICAgICAgZWxlbWVudHNbaV0gPSBkZWZhdWx0X3ZhbHVlOwogICAgfQoKICAgIFQgYXQodW5zaWduZWQgaW5kZXgpIGNvbnN0IAogICAgewogICAgICAgIGlmICggaW5kZXggPCB2dHJfc2l6ZSkgCiAgICAgICAgICAgIHJldHVybiBlbGVtZW50c1tpbmRleF07IAoKICAgICAgICByZXR1cm4gVCgpOwogICAgfQoKICAgIHVuc2lnbmVkIHNpemUoKSBjb25zdCB7IHJldHVybiB2dHJfc2l6ZTsgfQp9OwoKdGVtcGxhdGUgPHR5cGVuY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