数组指针变量形参与实参的传递
#include <stdlib.h>#include <stdio.h>
#define N 10
double fun(double *x)
{ int i, j; double av, y[N];
av=0;
for(i=0; i<N; i++)
/**********found**********/
av+=x[i]/N;
for(i=j=0; i<N; i++)
if( x[i]<av ){
y[j]=x[i]; x[i]=-1;
/**********found**********/
j++;
}
i=0;
while(i<N)
{ if( x[i]!= -1 ) y[j++]=x[i];
/**********found**********/
i++;
}
for(i=0; i<N; i++)x[i] = y[i];
return av;
}
main()
{ int i; double x[N];
for(i=0; i<N; i++){ x[i]=rand()%50; printf("%4.0f ",x[i]);}
printf("\n");
printf("\nThe average is: %f\n",fun(x));
printf("\nThe result :\n",fun(x));
for(i=0; i<N; i++) printf("%5.0f ",x[i]);
printf("\n");
}
子程序中x[i]应该是主程序中x[i]的地址还是其值?为什么