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

推荐订阅源

The Hacker News
The Hacker News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
小众软件
小众软件
云风的 BLOG
云风的 BLOG
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
L
LangChain Blog
博客园 - 司徒正美
腾讯CDC
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
S
Schneier on Security
T
Tailwind CSS Blog
S
Securelist
P
Proofpoint News Feed
A
Arctic Wolf
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy & Cybersecurity Law Blog
爱范儿
爱范儿
G
GRAHAM CLULEY
F
Full Disclosure
T
Threat Research - Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
T
Tor Project blog
T
Threatpost
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
C
CERT Recently Published Vulnerability Notes
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
Simon Willison's Weblog
Simon Willison's Weblog
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
I
Intezer
GbyAI
GbyAI
T
The Exploit Database - CXSecurity.com
L
LINUX DO - 热门话题
J
Java Code Geeks
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
罗磊的独立博客

博客园 - L.Zhang

.Net Remoting RMI框架 自己开发连接池 JDBC访问数据库 MyEclipse下开发Web Service 使用传统的XMLHttpRequest发出Ajax请求 XML CDATA XPath 数据库操作的sql脚本 直接插入排序 气泡排序 Builder 生成器模式(创建型模式) Abstract Factory 抽象工厂模式(创建型模式) Factory Method 工厂方法模式(创建型模式) Singleton单件模式(创建型模式) 使用Profile Service 服务端如何使用Session 让服务端返回xml 用Get方式访问
直接选择排序
L.Zhang · 2007-11-02 · via 博客园 - L.Zhang

namespace SelectSort
{
    
public partial class frmMain : Form
    {
        
struct rectype
        {
            
public int key;
            
public string other;
        }
private rectype[] r;
        
private const int n = 10;/// <summary>
        
/// 构造函数
        
/// </summary>
        public frmMain()
        {
            InitializeComponent();

            r 

= new rectype[n];

            Random ran 

= new Random();for (int i = 0; i < n; i++)
            {
                r[i].key 
= ran.Next(100);
                r[i].other 
= "我是" + r[i].key;
                
this.lbUnSort.Items.Add(r[i].other);
            }
        }
/// <summary>
        
/// 开始排序
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        private void btnSort_Click(object sender, EventArgs e)
        {
            
this.SELECTSORT();for (int i = 0; i < n; i++)
            {
                
this.lbSort.Items.Add(r[i].other);
            }

        }

/// <summary>
        
/// 排序算法
        
/// </summary>
        private void SELECTSORT()
        {
            
int i, j, k;
            rectype temp;
for (i = 0; i < n - 1; i++)
            {
                k 
= i;
                
for (j = i + 1; j < n; j++)
                {
                    
if (r[j].key < r[k].key)
                    {
                        k 
= j;
                    }
                }
if (k != i)
                {
                    temp 
= r[i];
                    r[i] 
= r[k];
                    r[k] 
= temp;
                }
            }
        }
    }
}