ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

十大排序算法之桶排序

十大排序算法之桶排序 桶排序步骤1.将值域分成若干段每段置于桶中2.将待排序元素放入对应桶中3.将个桶内的元素进行排序4.将桶中的元素依次取出列如1 3 5 4 1 6 2 1 3 9 8 71112334567891 2 3 4 5 6 7 8 9 10从桶中取出依次排序111233456789import java.util.*; public class Main { public static void main(String[] args) { Scanner scannew Scanner(System.in); int[] anew int[(int) 5e5]; int nscan.nextInt(); for (int i 0; i n; i) { int sscan.nextInt(); a[s]; } for (int i 0; i n; i) { for (int i1 1; i1 a[i]; i1) { System.out.print(i ); } } } }输入5 4 3 2 1 5 输出结果1 2 3 4 5十大排序算法之插入排序-CSDN博客十大排序算法之冒泡排序-CSDN博客
返回列表