其他分享
首页 > 其他分享> > E - Vector-Erase

E - Vector-Erase

作者:互联网

在这里插入图片描述

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<map>
#include<vector>
#include<set> 
using namespace std;
     vector<int>vv;
int main()
{ 
	int n,st,s,t,m;
	cin>>n;
	for(int i=0;i<n;i++)
	{
			cin>>m;
			vv.push_back(m);//依次把数存在栈底
	}

	cin>>st;
	cin>>s>>t;
	vv.erase(vv.begin()+st-1);//因为数组是从0开始的,
	vv.erase(vv.begin()+s-1,vv.begin()+t-1);
	cout<<vv.size()<<endl;
	for(int i=0;i<vv.size();i++)
	{
		if(i==0)
		cout<<vv[i];
		else
		cout<<" "<<vv[i];
	}
	cout<<endl;
	//cout<<vv[i]<<endl;
	//cout<<vv[vv.size()-1]<<endl;
	return 0; 
}

标签:begin,Vector,int,cin,st,Erase,vv,include
来源: https://blog.csdn.net/weixin_51713993/article/details/115635287