首页 > 编程语言 > 详细

冒泡排序

时间:2015-08-09 18:43:46      阅读:242      评论:0      收藏:0      [点我收藏+]
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 
 5 namespace 数组
 6 {
 7     class Program
 8     {
 9         static void Main(string[] args)
10         {
11             int [] szA={19,20,44,21,93,11,35,13,9,55};
12             
13            
14             for (int j = 0; j < szA.Length-1; j++)
15             {
16                 
17                 for (int i = 0; i <szA.Length-1 ; i++)
18                 {
19                     if (szA[i] >szA[i+ 1])//大于为正序,小于为倒序
20                     {
21                         
22                     int t = szA[i];
23                         szA[i] = szA[i + 1]; 
24                         szA[i + 1] = t;
25                     }
26                   
27                 }
28             }
29             foreach(int Int in szA)
30             Console.WriteLine(Int+" ");
31             Console.ReadLine();
32     
33                 
34         }
35     }
36 }

 

冒泡排序

原文:http://www.cnblogs.com/zxm1002/p/4715565.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!