惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
博客园 - 【当耐特】
小众软件
小众软件
博客园 - Franky
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
雷峰网
雷峰网
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Last Week in AI
Last Week in AI
博客园_首页
月光博客
月光博客
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
云风的 BLOG
云风的 BLOG
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Docker
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
DataBreaches.Net
S
Security @ Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
S
Security Affairs
Y
Y Combinator Blog
O
OpenAI News
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
K
Kaspersky official blog
Cloudbric
Cloudbric

博客园 - 三文鱼

叶问 弧线枪法 我是传奇 赤壁~之战 也说动物园展示蟒蛇吃活鸡 终于知道g9是谁了 人生的蝴蝶效应 杭州之行 广州车展 西安之行 变形金刚真是火 C#写的几个基本的排序算法(三) C#写的几个基本的排序算法(一) 数据库惊现"NULL" 换了个计数器 应该了解的垃圾收集机制(二) 应该了解的垃圾收集机制(一) 中国队输了 别把代码写成“密码”
C#写的几个基本的排序算法(二)
三文鱼 · 2007-06-27 · via 博客园 - 三文鱼

快速排序:

 1class QuickSortSample
 2    {
 3        CommonFunctions<int> _funcs = new CommonFunctions<int>();
 4
 5        public void Sort(int[] values, int begin, int end)
 6        {
 7            if (begin < end)
 8            {
 9                int p = Partition(values, begin, end);
10
11                Sort(values, begin, p - 1);
12                Sort(values, p + 1, end);
13            }

14        }

15
16        public int Partition(int[] values, int begin, int end)
17        {
18            int i = begin - 1;
19            
20            for (int j = begin; j < end ; j++)
21            {
22                if (values[j] < values[end])
23                {
24                    i++;
25                    _funcs.ExchangValues(ref values[j], ref values[i]);
26                }

27            }

28
29            i++;
30            _funcs.ExchangValues(ref values[i], ref values[end]);
31
32            return i;
33        }

34
35        static void Main()
36        {
37            int[] values = {4375890126 };
38
39            QuickSortSample quickSort = new QuickSortSample();
40            quickSort.Sort(values, 0, values.Length - 1);
41
42            foreach (int i in values)
43            {
44                Console.Write(i + "  ");
45            }

46        }

47    }