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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - iCeSnaker

[转载]两个未公开的ACCESS方法的使用技巧 Microsoft SQL Reporting Services – Running a Report from the Command Line Microsoft AntiSpyware Beta1 发布了,贴几张图片上来 大型组图:微软总部印象 两个桌面主题 [讨论] 制作博客园年刊 用C#实现生成PDF文档 C# Delegate 简介 单元测试的基本方法 小软件项目开发的管理 C#中为DataGrid添加下拉列表框 用C#读取XML文档 什么是需求? 呐喊 -- 希望博客圆一直是世外桃源 将sql server中的数据倒入Excel(c#) 在.net中轻松掌握Windows窗体间的数据交互(三) 在.net中轻松掌握Windows窗体间的数据交互(二) 在.net中轻松掌握Windows窗体间的数据交互(一) C# 编码规范和编程好习惯
C#实现的基本算法
iCeSnaker · 2004-08-09 · via 博客园 - iCeSnaker

冒泡法:

Using directives

namespace BubbleSorter
{
    
public class BubbleSorter
    
{
        
public void Sort(int[] list)
        
{
            
int i, j, temp;
            
bool done = false;
            j 
= 1;
            
while ((j < list.Length) && (!done))
            
{
                done 
= true;
                
for (i = 0; i < list.Length - j; i++)
                
{
                    
if (list[i] > list[i + 1])
                    
{
                        done 
= false;
                        temp 
= list[i];
                        list[i] 
= list[i + 1];
                        list[i 
+ 1= temp;
                    }

                }

                j
++;
            }

        }

    }

    
public class MainClass
    
{
        
public static void Main()
        
{
            
int[] iArrary = new int[] 151361055992871234753347 };
            BubbleSorter sh 
= new BubbleSorter();
            sh.Sort(iArrary);
            
for (int m = 0; m < iArrary.Length; m++)
                Console.Write(
"{0}", iArrary[m]);
            Console.WriteLine();
        }

    }

}

选择排序法

Using directives

namespace SelectionSorter
{
    
public class SelectionSorter
    
{
        
private int min;
        
public void Sort(int[] list)
        
{
            
for (int i = 0; i < list.Length - 1; i++)
            
{
                min 
= i;
                
for (int j = i + 1; j < list.Length; j++)
                
{
                    
if (list[j] < list[min])
                        min 
= j;
                }

                
int t = list[min];
                list[min] 
= list[i];
                list[i] 
= t;
            }

        }

    }

    
public class MainClass
    
{
        
public static void Main()
        
{
            
int[] iArrary = new int[] 1536105592871234753347 };
            SelectionSorter ss 
= new SelectionSorter();
            ss.Sort(iArrary);
            
for (int m = 0; m < iArrary.Length; m++)
                Console.Write(
"{0}", iArrary[m]);
            Console.WriteLine();
        }

    }

}

插入排序法

Using directives

namespace InsertionSorter
{
    
public class InsetionSorter
    
{
        
public void Sort(int[] list)
        
{
            
for (int i = 1; i < list.Length; i++)
            
{
                
int t = list[i];
                
int j = i;
                
while ((j > 0&& (list[j - 1> t))
                
{
                    list[j] 
= list[j - 1];
                    
--j;
                }

                list[j] 
= t;
            }

        }

    }

    
public class MainClass
    
{
        
public static void Main()
        
{
            
int[] iArrary = new int[] 113361055982871234753347 };
            InsertionSorter ii 
= new InsertionSorter();
            ii.Sort(iArrary);
            
for (int m = 0; m < iArrary.Length; m++)
                Console.Write(
"{0}", iArrary[m]);
            Console.WriteLine();
        }

    }

}

希尔排序法

Using directives

namespace ShellSorter
{
    
public class ShellSorter
    
{
        
public void Sort(int[] list)
        
{
            
int inc;
            
for (inc = 1; inc <= list.Length / 9; inc = 3 * inc + 1) ;
            
for (; inc > 0; inc /= 3)
            
{
                
for (int i = inc + 1; i <= list.Length; i += inc)
                
{
                    
int t = list[i - 1];
                    
int j = i;
                    
while ((j > inc) && (list[j - inc - 1> t))
                    
{
                        list[j 
- 1= list[j - inc - 1];
                        j 
-= inc;
                    }

                    list[j 
- 1= t;
                }

            }

        }

    }

    
public class MainClass
    
{
        
public static void Main()
        
{
            
int[] iArrary = new int[] 151361055992871234753347 };
            ShellSorter sh 
= new ShellSorter();
            sh.Sort(iArrary);
            
for (int m = 0; m < iArrary.Length; m++)
                Console.Write(
"{0}", iArrary[m]);
            Console.WriteLine();
        }

    }

}

果然,数据结构和算法是万变不离其宗之根本~