题解 | #创建动态数组#
创建动态数组
https://www.nowcoder.com/practice/218b577112a24c23a41bdc01f28c18ac
#include <iostream> using namespace std; int main() { int n; cin >> n; // write your code here...... int* p = new int[n]; //给数组元素赋值 for (int i = 0; i < n; i++) { p[i] = n + i; } //输出数组中的元素 for (int i = 0; i < n; i++) { cout << p[i] << " "; } delete [] p; return 0; }