What is the sorting method of Java selection?
The main content of this article is to explain "what is the sorting method of Java selection". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what is the Java selection sorting method"!
The selected sorting method is used to sort a group of data from small to large, and the data are 526, 36, 2, 369, 56, 45, 78, 92, 125 and 52, respectively.
1. The basic algorithm of program analysis selection sorting is to select the smallest array from the interval to be sorted and store it in a [0], then select the smallest value from the remaining sorting interval and store it in a [1], and the number in a [1] is only greater than a [0], and so on, that is, to realize the selection sorting.
2. Program realization
/ * Topic: sort a set of data from small to large by the method of selective sorting The data are * 526, 36, 2, 369, 56, 45, 78, 92, 125, 52 * File Name: Selection_sort * Author: Jack Cui * Created: 31 March 2016 * / # include / * Select sort function declaration * / int* Selection_sort (int* pDataArray Int iDataNum) Void main (void) {int itint iArray [10]; printf ("Please enter 10 numbers:\ n"); for (I = 0
< 10;i++) scanf("%d",&iArray[i]); Selection_sort(iArray,10); printf("快速排序后的顺序为:\n");for(i = 0;i < 10;i++) printf("%5d",iArray[i]); printf("\n");}/***********************************函数名称:Selection_sort*参数说明:pDataArray 无序数组* iDataNum为无序数据个数*说明: 快速排序***********************************/int* Selection_sort(int* pDataArray,int iDataNum){int i,j,iDataTemp;for(i = 0;i < 9;i++)for(j = i + 1;j < 10;j++)if(pDataArray[i] >PDataArray [j]) {iDataTemp = pDataArray [I]; pDataArray [I] = pDataArray [j]; pDataArray [j] = iDataTemp;} return pDataArray;}
3. Result display (eclipse)
At this point, I believe that everyone on the "Java selection sorting method is what" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!