Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Customize a sorting function, call it in the main function, and sort the elements of the integer array from large to small.
Customize a sorting function, call it in the main function, and sort the elements of the integer array from large to small.
# include & ltstdio.h & gt

void sort(int a[],int n)

{

int i,j,index,temp

for(I = 0; I<n-1; i++)

{

index = I;

for(j = I+ 1; j & ltn; j++)

{

if(a[index]& gt; a[j])

index = j;

}

temp = a[I];

a[I]= a[index];

a[index]= temp;

}

}

int main()

{

int I;

int a[ 10]={ 1,3,4,2,6,7,9, 10,8,5 };

Sorting (a,10);

for(I = 0; I< 10; i++)

printf("%d ",a[I]);

Returns 0;

}