#include <stdio.h>
void max(int *p,int n);
int main()
{
int a[6]={10,11,12,12,13,15};
int size = sizeof(a)>>2;
printf("数据个数%d\n",size);
max(a,size);
return 0;
}
void max(int *p,int n)
{
int max = p[0];
//int size2 = sizeof(p);这里不对,永远8位,指针长度
for(int i = 0;i < n;i++)
{
printf("p[%d]=%d\n",i,p[i]);
if(p[i]>max)
max = p[i];
}
printf("max=%d\n",max);
} |