码迷,mamicode.com
首页 > 编程语言 > 详细

关于冒泡排序

时间:2015-03-20 18:22:30      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace ConsoleApplication1
 8 {
 9     class Program
10     {
11 
12         static void Main(string[] args)
13         {
14             int[] number = { 1,2,3,4,3,2,4,67,5,3,2,12,-1,-4252,34};
15             for (int i = 0; i < number.Length; i++)
16             {
17                 for (int j = 0; j < number.Length-1-i; j++)
18                 {
19                     if(number[j+1]>number[j])  //从大到小排列
20                     {
21                         int num = number[j + 1];
22                         number[j + 1] = number[j];
23                         number[j] = num;
24                     }
25                 }
26             }
27             for (int i = 0; i < number.Length; i++)
28             {
29                 Console.Write(number[i]+"\r\n");
30             }
31             Console.ReadKey();
32          }
33 }

 

关于冒泡排序

标签:

原文地址:http://www.cnblogs.com/workcn/p/4353937.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!