冒泡排序-方法2
2015-08-11 08:22
411 查看
using System.Threading; namespace 由小到大 { class Program { static void Main(string[] args) { Console.Write("输入个数:"); int[] a = new int[int.Parse(Console.ReadLine())]; int i = a.Length; for (int b = 0; b < i; b++) { Thread.Sleep(500); Random r = new Random(); a[b] = r.Next(1, 99); Console.Write(" " + a[b]); } Console.Write("\n由小到大"); int x, y; for ( x = 0; x < i; x++) { for ( y = x; y < i ; y++) { if (a[x] > a[y]) { int k = a[y]; a[y] = a[x]; a[x] = k; } } Console.Write(" " + a[x]); } //foreach(int k in a ) //Console.Write(" " + k]); Console.ReadLine(); } } }
相关文章推荐
- Java实现与调用Web Service
- ios学习(UIScrollView)
- 抽象工厂
- vss2005使用
- 二维码 zxing
- [LeetCode]Two Sum
- 从HelloWorld开始
- BZOJ3052: [wc2013]糖果公园
- hdu3586 Information Disturbing(树状DP+二分查找)
- cordova百度导航插件使用
- 开源 自由 java CMS - FreeCMS1.9 分纪录
- hdoj 4081 Qin Shi Huang's National Road System 【次小生成树变形】
- 糙米粗粮
- 【Oracle】PL/SQL实现打印1-100中的素数
- POJ 3189 Steady Cow Assignment
- mysql 的安装和配置
- hdu 1162
- 磁盘映射(Net use)
- ViewDragHelper实战 自己打造Drawerlayout
- ViewDragHelper实战 自己打造Drawerlayout