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

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - John Yang

【转】批处理命令基础教程 《Transact-sql权威指南》学习日记 安装与配置IIS 设计原则 一些常见的C#面试问题和答案 什么是SQL注入式攻击 什么是手册报关 策略模式 C#入门(一) 什么是PMP认证 - John Yang - 博客园 [好文共享] 哈佛讲师讲授幸福:我们越来越富有为何仍不开心 设计模式之工厂模式 42个项目管理过程 项目管理过程组与知识领域表 背完这444句,你的口语绝对不成问题了 SQL SERVER性能优化 [白领栏目] 创造“我生命中的鼎盛之年”五大原则 【三星系列】真正的三星F278秘笈 让人生成功的49个细节
排序算法
John Yang · 2010-07-29 · via 博客园 - John Yang

1.冒泡排序法

冒泡排序算法核心循环代码

 1 for (int i = 0; i < num.Length - 1; i++)
 2 {
 3     for (int j = 0; j < num.Length - 1 - i; j++)
 4     {
 5          if (num[j] > num[j + 1])
 6          {
 7               int temp = num[j];
 8               num[j] = num[j + 1];
 9               num[j + 1= temp;
10          }
11      }
12  }

2.选择排序算法

代码

 1         private static int[] SelectionSort(int[] x)
 2         {
 3             int[] temp = x;
 4             int big = 0;
 5             int index = 0;
 6 
 7             for (int i = 0; i < x.Length; i++)
 8             {
 9                 index = i;
10 
11                 for (int j = i+1; j < x.Length; j++)
12                 {
13                     if (temp[j] > temp[index])
14                     {
15                         index = j; 
16                     }
17                 }
18 
19                 if (i != index)
20                 {
21                     big = temp[index];
22                     temp[index] = temp[i];
23                     temp[i] = big;
24                 }
25             }
26                         
27             return temp;
28         }