排序篇_简单桶排序

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();
        }
    
    }
}

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

优点:简单易懂。

posted @ 2016-01-21 15:50  春秋一梦  阅读(279)  评论(0编辑  收藏  举报