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

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - Sandy

外贸网站 Jmail邮件发送程序... - Sandy - 博客园 windows错误代码详解 VIVR 主源程... VIVR 转人工函数 - Sandy - 博客园 VIVR 语音留言函数 - Sandy - 博客园 VIVR 发送传真函数 VIVR 接受传真函数 - Sandy - 博客园 VIVR 收听语音留言函数 - Sandy - 博客园 asp函数表 地道英国习语50条 Money can buy happiness, up to a point 得到星期的sql语句和得到月末的sql语句 Who Is Going to Eat It? 建立一个传表名参数的存储过程 北京今天中午感觉到地震 相信自己... 服务器控件和客户端控件的区别 Ajax原理详细说明(转自ibm开发者网站)
C#版,冒泡排序-----C#,BubbleSort
Sandy · 2006-07-11 · via 博客园 - Sandy

using System;

namespace ConsoleApplication1
{
 /// <summary>
 /// Class1 的摘要说明。
 /// </summary>
 class Class1
 {
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {
   //
   // TODO: 在此处添加代码以启动应用程序
   //
   aa();
  }
  public static void aa()
  {
   int[] r = new int[] {3,4,7,6,2,9};
   bubblesort(ref r);
   for(int i = 0; i < r.Length; i ++)

   Console.Write(r[i]);
  }

  public static void bubblesort(ref int[] r)
   {
    int i,j,temp; //交换标志

    bool exchange;

    for(i=0; i<r.Length; i++) //最多做r.length-1趟排序
    {
    exchange=false; //本趟排序开始前,交换标志应为假

    for(j=r.Length-2; j>=i; j--)
    {
    if(r[j+1]<r[j]) ////交换条件
    {
     temp=r[j+1];
     r[j+1]=r[j];
     r[j]=temp;

     exchange=true; //发生了交换,故将交换标志置为真
    }
    }

    if(!exchange) //本趟排序未发生交换,提前终止算法
    {
    break;
    }
    }
   }
 }
}