#include<stdio.h>
void swap(int* pa, int* pb)
{
int t;
t = *pa; *pa = *pb; *pb = t;
}
int main()
{
int arr[4] = { 0 };
int i, j , n=4;
for (i = 0; i < 4; i++)
{
scanf("%d", &arr[i]);
}
for (i = 0; i < n - 1; i++)
{
for (j = i + 1; j < n; j++) {
if (arr[j] > arr[i])
{
swap(&arr[j],&arr[i]);
}
}
}
for (i = 0; i < 4; i++)
{
printf("%d", arr[i]);
printf(" ");
}
return 0;
}
标签:arr,函数,实现,++,pb,int,pa,swap,指针 From: https://blog.csdn.net/2401_88256180/article/details/144654811