#include <stdio.h>intMain () {inti,j; inta[Ten]; intiTemp; intIPos; printf ("assign value to an array element: \ n"); //Assigning a value to an array by using the keyboard for(i=0;i<Ten; i++) {printf ("a[%d]=", i); scanf ("%d",&A[i]); } //start sorting core programs from small to large for(i=0;i<9; i++)//0 1 2 3 4 5 6 7 8 9 cycles Outer Loop{iTemp=A[i]; IPos=i; for(j=i+1;j<Ten; j + +)//j = 1 2 3 4 5 6 7 8 9 9 Cycles { if(a[j]<iTemp) {ITemp=A[j]; IPos=J; } } } //Exchange values for two elementsa[ipos]=A[i]; A[i]=iTemp; //Output Array for(i=0;i<Ten; i++) {printf ("%d\t", A[i]); if(i==4) printf ("\ n"); } return 0 ;} Operation results This sort method has a problem with big numbers, but I don't understand this sort of algorithm ... [Email protected]:~/cprogram#./x Selection method ordering. outAssigning a value to an array element: a[0]=1123a[1]=123a[2]=123a[3]= -a[4]= Aa[5]= toa[6]= ata[7]= +a[8]=3213a[9]= A1123 123 123 - A to at + 3213 A[e-mail protected]:~/cprogram#./x Select to sort by.] outAssigning a value to an array element: a[0]=1a[1]=2a[2]=3a[3]=4a[4]=5a[5]=6a[6]=7a[7]=8a[8]=9a[9]=01 2 3 4 5 6 7 8 9 0[Email protected]:~/cprogram#
Two-bit array-select sort