摘要
使用传统的快速排序、堆排序和归并排序方法受到比较次数影响,导致排序结果不精准,为了解决该问题,提出在C语言程序设计中选择结构排序算法。依据选择结构排序算法原理,对C语言数组Bs中的5组数据进行了排序,5组数组中共排序4趟,第1趟比较4次,第2趟比较3次,第3趟比较2次,第4趟比较1次,由此确定每趟排序交换后的数据排序结果,完成C语言升序排序设计。设计if选择语句的多选择结构格式,依据该格式判断语句真假,完成C语言计算程序设计。由实验结果可知,该方法排序结果较为精准。
The use of traditional quick sort,heap sort and merge sort methods are affected by the number of comparisons,resulting in inaccurate sort results.In order to solve this problem,a structural sort algorithm was proposed in C language programming.According to the principle of the sorting algorithm of the selected structure,the 5 groups of data in the C language array Bs were sorted.There are a total of 4 sorts in the 5 groups.The first comparison is 4 times,the second comparison is 3 times,and the third comparison is 2 times.The 4th pass compares once to determine the data sorting result after each sorting exchange,and complete the C language ascending sorting design.Design the multi-choice structure format of the if selection sentence,judge the true or false of the sentence according to the format,and complete the C language calculation program design.It can be seen from the experimental results that the ranking results of this method are more accurate.
作者
张晨
ZHANG Chen(Scool of Urban Construction,Anhui Jianzhu University,Hefei,238076,Anhui)
出处
《蚌埠学院学报》
2021年第5期54-56,97,共4页
Journal of Bengbu University
基金
安徽高校自然科学研究重点项目(KJ2020A1213)。
关键词
C语言程序
选择结构
排序算法
数据排序
C language program
select the structure
sorting algorithm
data sorting