我需要使用向量向量创建一个二维数组,并且要初始化该行,您需要使用初始值设定项作为向量构造函数的实际参数。你能告诉我“初始化器是什么意思是矢量构造函数的实际参数”吗?
答案 0 :(得分:0)
i = 0
while i < len(my_list) :
print( str(i + 1) + '. ' + str(my_list[i]) )
i += 1
这将创建一个行* cols 2D数组,其中每个元素为0.默认值为std :: vector(cols,0),这意味着每行都有一个向量,其中cols number为element,每个为0。
答案 1 :(得分:0)
你能告诉我“初始化器是什么意思是矢量构造函数的实际参数”吗?
构建一维矢量
// Construct a 1D vector with the elements {10, 20, 30, 40}
std::vector<int> v1 = {10, 20, 30, 40};
构建2D矢量
// Construct a 2D vector with 2 rows and 3 colomns.
// First row has the elements {10, 20, 30}
// Second row has the elements {40, 50, 50}
std::vector<std::vector<int>> v2 = {{10, 20, 30}, {40, 50, 60}};