题解 | 创建动态数组
创建动态数组
https://www.nowcoder.com/practice/218b577112a24c23a41bdc01f28c18ac
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
// write your code here......
vector<int> v;
for (int i = n; i <= 2 * n - 1; i++) {
v.push_back(i);
}
for (int j = 0; j < v.size() - 1; j++) {
cout << v[j] << " ";
}
cout << v[v.size() - 1];
return 0;
}
查看7道真题和解析