<<Vector-Erase>> _HakerRank_C++_STL

#include <cmath>#include <cstdio>#include <vector>#include <iostream>#include <algorithm>using namespace std;int main() {    /* Enter your code here. Read input from STDIN. Print output to STDOUT */    int n = 0 , m = 0;     cin >> n ;        vector<int> vec(n);    for(int i = 0 ; i < n ; i++)    {       cin >> vec[i] ;    }        // erase the n-th element    cin >> n ;    vec.erase(vec.begin()+(n-1));        // erase the n-th to m-th elements:     cin >> n >> m;    vec.erase(vec.begin()+(n-1) , vec.begin()+m-1);        cout << vec.size() << endl;    for(n =0 ; n< vec.size() ; n++)    {        cout << vec[n] << " " ;      }           return 0;}

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章