码迷,mamicode.com
首页 > 编程语言 > 详细

排序篇_简单桶排序

时间:2016-01-21 18:38:22      阅读:180      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!