编写一个程序,通过指针变量找出一维数组中的最大值和最小值,并交换最大值和最小值的位置.

问题描述:

编写一个程序,通过指针变量找出一维数组中的最大值和最小值,并交换最大值和最小值的位置.

#include
#include
int main()
{ int i,a[10]={1,3,2,4,5,6,10,7,8,9};
int *max,*min,temp;
max=malloc(sizeof(int));
min=malloc(sizeof(int));
*max=0;*min=0;
for(i=1;ia[*max])*max=i;
if(a[i]