百度首页 | 百度空间
 
查看文章
 
冒泡排序算法
2008-04-27 14:57

class Program
    {
       
        static void Main(string[] args)
        {
            int[] sortArry ={ 0, 5, 6, 2, 1 };
            for (int i = 0; i < sortArry.Length; i++)
            {
                for (int j = i+1; j <sortArry.Length; j++)
                {
                    if (sortArry[j]<sortArry[i])
                    {
                        int temp = sortArry[i];
                        sortArry[i] = sortArry[j];
                        sortArry[j] = temp;
                    }
                }
            }

            foreach (int i in sortArry)
            {
                Console.WriteLine(i);
            }

        }
      

    }


类别:.net开发 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu