题解 | #创建动态数组#
创建动态数组
http://www.nowcoder.com/practice/218b577112a24c23a41bdc01f28c18ac
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
// write your code here......
int *p=(int*)malloc(n * sizeof(int));
int *q=p;
int num=n;
for(int i=0;i<n;i++){
*q = num++;
q++;
}
for(int i=0;i<n;i++){
if(i==(n-1)){
cout<<*p<<endl;
}else{
cout<<*p<<" ";
}
p++;
}
return 0;
}