梅开二度 激情超越

~~常用激扬的句子去激励自己的学生,为什么自己却莫名的沉沦了!~~

C#算法----冒泡排序

程序代码


using System;

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[]{1,5,13,6,10,55,99,2,87,12,34,75,33,47};
   BubbleSorter sh=new BubbleSorter();
   sh.Sort(iArrary);
   for(int m=0;m<iArrary.Length;m++)
    Console.Write("{0} ",iArrary[m]); 
   Console.WriteLine();
  }
 }
}

posted on 2006-12-28 14:12 梅开二度 激情超越 阅读(67) 评论(0)  编辑 收藏 引用 网摘 所属分类: Asp.NET


只有注册用户登录后才能发表评论。

My Links

Blog Stats

留言簿(3)

随笔分类(22)

随笔档案(21)

文章分类(48)

文章档案(44)

相册

收藏夹(40)

Favorite site

My Friends

搜索

最新评论