Vector

#include <iostream>

#include<vector>

using namespace std;

int main()

{

int n;

int a[10];

a[10]=5;

int a[11];

vector <int> a;

a.push_back(1);//在a的末尾添加1

a.erase(a.begin(),a.end());//清空a

for(auto it=a.begin();it!=a.end();it++)

{

cout<<*it<<" ";//利用迭代器遍历a

}

for(int value:a)

{

cout<<value<<" ";

}

}

全部评论

相关推荐

06-12 16:00
天津大学 Java
牛客30236098...:腾讯坏事做尽,终面挂是最破防的 上次被挂了后我连简历都不刷了
点赞 评论 收藏
分享
自由水:笑死了,敢这么面试不敢让别人说
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务