1)  请用C#编写一个冒泡排序的程序, 
2)  要求排序的数据从文件C:\DATE.DAT中读取,数据间用逗号分隔。

解决方案 »

  1.   

    这么简单,哪本算法书都有冒泡的吧......
    你是要问算法还是问语法啊????
    要算法找算法书,要语法找MSDN...
      

  2.   

    for(int i=0;i<a.length-1;i++)
    {
      for(int j=1;j<a.length;j++)
       {
         //..向上冒或向下冒
        }
    }
      

  3.   

    public void BubbleSort(int[] R) 
      { 
       int i,j,temp;    bool exchange;    for(i=0; i<R.Length; i++) 
       {    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; 
       } 
       } 
      }
      

  4.   

    http://www.aspxboy.com/code
    other--stuff -- sorter
      

  5.   


    我这样写不行呢
    private void sort()
        {
            StreamReader sr = new StreamReader(@"C:\DATE.DAT");        //Response.Write(sr.ReadLine().ToString());        string[] text = sr.ReadLine().Length.ToString().;
            for (int i = 0; i < text.Length; i++)
            {
                string strText;
                for (int j = 0; j < i; j++)
                {
                    if (text[i] > text[j])
                    {
                        strText = text[i];
                        text[i] = text[j];
                        text[j] = strText;
                    }
                }
            }
        }