5 条题解
-
0
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> vec; for (int i = 0; i < n; i++) { int a; cin >> a; vec.push_back(a); } int x, y; cin >> x; cin >> y; vec.insert(vec.begin() + x - 1, y); for (const auto& elem : vec) { cout << elem << "\n"; } cout << endl; return 0; }
-
0
#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
#include <iostream> #include <vector> using namespace std;
int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int> arr; int n, num, pos, val; cin >> n; for (int i = 0; i < n; i++) { cin >> num; arr.push_back(num); } cin >> pos; cin >> val; arr.insert(arr.begin() + pos - 1, val); vector<int> ::iterator it; for (it = arr.begin(); it != arr.end(); it++) { cout << *it << endl; } return 0;
}
- 1
信息
- ID
- 71
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 369
- 已通过
- 181
- 上传者