怎把vector放入一个vector
时间: 2023-08-26 08:18:26 浏览: 77
how to use vector
要把一个vector的元素追加放入另一个vector,你可以使用insert函数。可以按照以下步骤进行操作:
1. 首先,创建两个vector对象,一个是源vector,一个是目标vector。比如说:std::vector<int> src; std::vector<int> dest;
2. 使用insert函数将源vector的元素追加到目标vector中。可以使用以下语句:dest.insert(dest.end(), src.begin(), src.end());<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vector 把一个vector追加到另一个vector](https://blog.csdn.net/Fly_as_tadpole/article/details/82710781)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [把一个vector里的元素全部放入另外一个vector](https://blog.csdn.net/junruitian/article/details/79928424)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [C++ vector](https://blog.csdn.net/m0_61548909/article/details/124215519)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文