#include <iostream>
#include <algorithm>
using namespace std;
class Vector {
size_t size;
double *elem;
public:
Vector(initializer_list<double> lst)
:size{lst.size()},elem{new double[lst.size()]}
{
std::copy(lst.begin(),lst.end(),elem);
}
void test() { for (int i=0; i<size; i++) cout<< elem[i]<<" "; cout<<endl; }
};
class Matrix{
private:
int row;
int col;
double **elem;
public:
//Default Constructor:
Matrix(int row,int col) { cout << "Other !!"<<endl; }
//Initialized list constructor:
Matrix(initializer_list<initializer_list<double>> lst) : row{lst.size()},col{0} {
for (auto &x: lst)
if (x.size()>col)
col = x.size();
cout<<row<<"x"<<col<<endl;
elem=new double*[row];
auto it=lst.begin();
for (int i=0; i<row; i++, it++) {
elem[i]=new double[col];
std::copy(it->begin(),it->end(),elem[i]);
}
}
void test() {
for (size_t i=0; i<row; i++) {
for (size_t j=0; j<col; j++)
cout<< elem[i][j]<<" ";
cout<<endl;
}
}
};
int main() {
Vector v{1,2,3,4,5,6,7,8,9,10,11};
v.test();
Matrix m{ {1,2,3},{4,5,6},{7,8,9}};
m.test();
Matrix l{1,2};
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgVmVjdG9yIHsKCXNpemVfdCBzaXplOyAKCWRvdWJsZSAqZWxlbTsgCnB1YmxpYzoKICAgVmVjdG9yKGluaXRpYWxpemVyX2xpc3Q8ZG91YmxlPiBsc3QpCiAgICA6c2l6ZXtsc3Quc2l6ZSgpfSxlbGVte25ldyBkb3VibGVbbHN0LnNpemUoKV19CiAgICB7CiAgICAgICAgc3RkOjpjb3B5KGxzdC5iZWdpbigpLGxzdC5lbmQoKSxlbGVtKTsKICAgIH0KICAgIHZvaWQgdGVzdCgpIHsgZm9yIChpbnQgaT0wOyBpPHNpemU7IGkrKykgY291dDw8IGVsZW1baV08PCIgIjsgY291dDw8ZW5kbDsgfQp9OwoKY2xhc3MgTWF0cml4ewpwcml2YXRlOgogICAgaW50IHJvdzsKICAgIGludCBjb2w7CiAgICBkb3VibGUgKiplbGVtOwpwdWJsaWM6CiAgICAvL0RlZmF1bHQgQ29uc3RydWN0b3I6CiAgICBNYXRyaXgoaW50IHJvdyxpbnQgY29sKSB7IGNvdXQgPDwgIk90aGVyICEhIjw8ZW5kbDsgfQogICAgLy9Jbml0aWFsaXplZCBsaXN0IGNvbnN0cnVjdG9yOgogICAgTWF0cml4KGluaXRpYWxpemVyX2xpc3Q8aW5pdGlhbGl6ZXJfbGlzdDxkb3VibGU+PiBsc3QpIDogcm93e2xzdC5zaXplKCl9LGNvbHswfSB7CiAgICAgICAgZm9yIChhdXRvICZ4OiBsc3QpIAogICAgICAgICAgICBpZiAoeC5zaXplKCk+Y29sKQogICAgICAgICAgICAgICAgY29sID0geC5zaXplKCk7CiAgICAgICAgY291dDw8cm93PDwieCI8PGNvbDw8ZW5kbDsgCiAgICAgICAgZWxlbT1uZXcgZG91YmxlKltyb3ddOyAKICAgICAgICBhdXRvIGl0PWxzdC5iZWdpbigpOyAKICAgICAgICBmb3IgKGludCBpPTA7IGk8cm93OyBpKyssIGl0KyspIHsKICAgICAgICAJZWxlbVtpXT1uZXcgZG91YmxlW2NvbF07CiAgICAgICAgCXN0ZDo6Y29weShpdC0+YmVnaW4oKSxpdC0+ZW5kKCksZWxlbVtpXSk7CiAgICAgICAgfQogICAgfQogICAgdm9pZCB0ZXN0KCkgeyAKICAgICAgICBmb3IgKHNpemVfdCBpPTA7IGk8cm93OyBpKyspIHsKICAgICAgICAJZm9yIChzaXplX3Qgaj0wOyBqPGNvbDsgaisrKSAKICAgICAgICAJICAgY291dDw8IGVsZW1baV1bal08PCIgIjsgCiAgICAgICAgCWNvdXQ8PGVuZGw7IAogICAgICAgIH0KICAgIH0KfTsKCmludCBtYWluKCkgewoJVmVjdG9yIHZ7MSwyLDMsNCw1LDYsNyw4LDksMTAsMTF9OyAKCXYudGVzdCgpOyAKCU1hdHJpeCBteyB7MSwyLDN9LHs0LDUsNn0sezcsOCw5fX07IAoJbS50ZXN0KCk7CglNYXRyaXggbHsxLDJ9OwoJcmV0dXJuIDA7Cn0=