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

推荐订阅源

D
Docker
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LangChain Blog
P
Privacy & Cybersecurity Law Blog
Hugging Face - Blog
Hugging Face - Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
A
Arctic Wolf
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
The GitHub Blog
The GitHub Blog
P
Privacy International News Feed
WordPress大学
WordPress大学
U
Unit 42
S
Securelist
T
The Exploit Database - CXSecurity.com
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
Latest news
Latest news
Hacker News: Ask HN
Hacker News: Ask HN
小众软件
小众软件
Know Your Adversary
Know Your Adversary
The Cloudflare Blog
V
Vulnerabilities – Threatpost
The Hacker News
The Hacker News
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
Security Latest
Security Latest
Google DeepMind News
Google DeepMind News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - Franky
Y
Y Combinator Blog
博客园 - 叶小钗
Security Archives - TechRepublic
Security Archives - TechRepublic
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
S
Secure Thoughts
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 司徒正美
M
MIT News - Artificial intelligence

博客园 - Nillson

传说中的Singleton.... 设计模式--简单工厂模式 策略模式 抽象类与接口 C# 实现的一个二叉树类 回顾一个面试题 再谈代理 预定义,宏定义 连接符,数值运算与函数 复杂查询 数据库中的Index和View的理解 重载和重写 采用递归的方法获得一棵树的所有叶节点 .NET中的新概念整理 4月要看的书 System.Runtime.InteropServices浅见 挂个牛人 一篇关于如何写注释的文章,值得收藏 Vistual Studio 2005到Vistual Studio 2008的版本转换问题 Visual Studio 2008 的一个Bug
常见的排序方法
Nillson · 2008-07-08 · via 博客园 - Nillson

插入排序

插入排序的思想是当我要插入第n个元素时,认为前n-1个元素已经是有序的。把第n个元素与前面的元素一次对比,找到合适的位置。然后是第n+1个元素.

void main()
{
    int a[6] = {1,5,3,6,8,2};
    int temp;
    for(int i = 1; i < 6; i++)//从第二个元素开始,依次与前面的有序数列进行比较
    {
        for(int j = i; j > 0; j--)//取待插入的元素依次与前面的元素进行比较如果小于前面的值则进行交换
        {
            if(a[j] < a[j-1])//
            {
                temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
            }
        }
    }
    for(int i = 0; i < 6; i++)
    {
        cout<<a[i]<<" ";
    }
}