可以使用变长数组或malloc函数动态分配内存。 变长数组: #include void array_show(const int ); int main(void) { int rows; puts("输入数组大小: "); scanf("%d", &rows); array_show(rows); return 0; } void array_show(const int cols) { int array[cols]; ………… ………… } malloc函数动态分配内存: #include #include void array_show(const int); int main(void) { int rows; puts("输入数组大小: "); scanf("%d", &rows); array_show(rows); return 0; } void array_show(const int cols) { int count; int * point = (int *)malloc(sizeof(int) * cols); for(count = 0; count < cols; cols++) { scanf("%d", &point[count]); } ………… ………… free(point); /* 把分配的内存释放掉 */ }
求采纳