Introduction to choosing a sort
Select the sort is the outer layer for the n-1, the inner layers of n-1, each trip to select the largest or smallest data on the front.
Second, code implementation
#include <stdio.h>/* Two data exchange/void Swap (int* Ina, int* Inb) {int temp = *ina;
*ina = *INB;
*INB = temp;
/* * Function function: Select the sort, the data from small to large sorting * parameter explanation: InArray input Array * Inlen input array length * * int selectsort (int* inarray,int inlen) {
int i = 0,j = 0;
if (InArray = NULL) return 1;
/* Outer loop/for (i = 0; i < InLen-1 i++) {/* Inner loop */for (j = i + 1; j < Inlen; J +) {/* always guarantee every time/if (Inarray[i] > Inarray[j]) {Swap (&inarray[i],&
AMP;INARRAY[J]);
}} return 0;
int main () {int a[] = {49,38,65,97,76,13,27};
int index = 0;
int len = sizeof (a)/sizeof (int);
/* First traverse the elements of the array to print/for (index = 0; index < len; index++) {printf ("%d", A[index]);
printf ("\ n");
/* Call the Select Sort function */selectsort (A,len); /* Iterate through the elements of the array * * for (index = 0; index < len; index++) {printf ("%d ", A[index]);
printf ("\ n");
return 0;
}