1. 传入函数的数组成了什么?
函数参数表中的数组实际上是指针,
sizeof(a) == sizeof(int*),
可以用数组运算符[]来进行计算,
以下四种函数原型等价。
int sum(int *arr, int n);
int sum(int *, int);
int sum(int arr[], int n);
int sum(int [], int);
#include <iostream>
using namespace std;
void minmax(int *a, int len, int *max, int *min);
int main()
{
int a[]={1,2,3,4,5,6,7,8,9,12,13,14,15,16,17,21,23,55};
int min,max;
minmax(a, sizeof(a)/sizeof(a[0]), &min,&max);
cout << "main a = " << a << endl;
cout<< "main sizeof(a)=" << sizeof(a)<< ", sizeof(a[0]) = "<<sizeof(a[0])<<endl;
return 0;
}
void minmax(int *a, int len, int*min, int *max)
{
cout << "min max a = " << a << endl;
cout<<"minmax sizeof(a)="<<si