我想编写一个函数,该函数将接受一个数组作为输入参数。该函数应打印出数组的所有元素。
print_array(arr) { //print all the elemnts of arr. }
我不知道如何做到那一点。
我认为首先我们需要找出传递的数组是一维、二维还是三维等等……的数组。
因为,要打印以下元素:
1-D array, you need only 1 for loop.
2-D array, you need only 2 for loop.
3-D array, you need only 3 for loop.
不过我不知道您如何确定它是一维、二维还是N维数组。请帮忙。
print_array(type *array, int n_dimensions, int *dimensions)
? - eq-