【发布时间】:2022-01-17 09:26:57
【问题描述】:
你会如何在 c++ 中编写列表乘以比例的代码?
在 python 中我会这样做:
lst = [1,2,3]
lst*3 # we will get [1,2,3,1,2,3,1,2,3]
c++ 的等价物是什么?
【问题讨论】:
-
没有内置任何东西。但是您可以重复使用向量连接。见stackoverflow.com/questions/201718/concatenating-two-stdvectors