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

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 03:24:54
编写一个程序,通过指针变量找出一维数组中的最大值和最小值,并交换最大值和最小值的位置.

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

编写一个程序,通过指针变量找出一维数组中的最大值和最小值,并交换最大值和最小值的位置.
#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]