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

推荐订阅源

雷峰网
雷峰网
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
L
LangChain Blog
云风的 BLOG
云风的 BLOG
Jina AI
Jina AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
小众软件
小众软件
量子位
The GitHub Blog
The GitHub 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;
    }
    }
   }
 }
}