方法一:申请大数组,浪费不可避免,使用数组时还要小心不能使用未初始化数组的元素
void main() { int a[100]; int i=0,j=0; printf("请输入数据,用空格间隔,回车结束:\n"); do { scanf("%d",&a[i++]); }while(getchar()!='\n'); for(j=0;j<i;j++) { printf("%d ",a[j]); }<pre name="code" class="html">
方法二:动态申请
方法一:申请大数组,浪费不可避免,使用数组时还要小心不能使用未初始化数组的元素
void main() { int a[100]; int i=0,j=0; printf("请输入数据,用空格间隔,回车结束:\n"); do { scanf("%d",&a[i++]); }while(getchar()!='\n'); for(j=0;j<i;j++) { printf("%d ",a[j]); }<pre name="code" class="html">