首页 > 编程语言 > 详细

排序篇_简单桶排序

时间:2016-01-21 18:35:29      阅读:207      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DemoSort1_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[]  s={10,36,58,24,69,12,85,100,99,34,12,54,7};
            int[] a = new int[101];
            for (int i = 0; i < s.Length; i++)
            {
                a[s[i]]++;
            }
            for (int j = 0; j < a.Length; j++)
            {
                if (a[j] > 0)
                {
                    for (int t = 0; t < a[j]; t++)
                    {

                        Console.Write(j.ToString()+"   ");
                    }
                }
            }

            Console.ReadLine();
        }
    
    }
}

缺点:事先要知道,待排序数组最大值。

优点:简单易懂。

排序篇_简单桶排序

原文:http://www.cnblogs.com/kim-meng/p/5148542.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!