返回题解分享
讨论 / 题解分享/ 帖子详情

vector插入 - 题解

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    vector<int> a;
    int n, t, pos;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> t;
        a.push_back(t);
    }

    cin >> pos;
    cin >> t;
    a.insert(a.begin() + pos - 1, t);
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << endl;
    }

    return 0;
}
0 回复 0 转发 0 喜欢 7 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!