Create array with different sizes of array in C++

Viewed 27

One can generate list with different length of list in python :

layers = 3
lst = []
for i in range(1, layers+2):
    lst.append([0]*i)

Above code generates 2d list:

[[0],
 [0, 0],
 [0, 0, 0],
 [0, 0, 0, 0]]

So how can I create a 2d array like the 2d list above in C++?

Thanks!

0 Answers
Related