C#数组冒泡排序
2016-03-25 16:55
477 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { public static void Pop(int n,int []x) { for (int i = 0; i < n-1; ++i) { for (int j = 0; j < n - i - 1; ++j) { if (x[j] > x[j+1]) { int a = x[j]; x[j] = x[j+1]; x[j+1] = a; } } } } static void Main(string[] args) { int []a={2,3,8,9,4,6,7,1,0,5}; Pop(10, a); foreach (int item in a) { Console.WriteLine(item); } Console.ReadKey(); } } }
运行结果:
相关文章推荐
- C# 文件压缩与解压(ZIP)基于 .Net Framework
- C#Chart 格控件的一些使用心得
- .NET/C# RabbitMQ
- C#——Random类猜数字
- C#上机实验(二)
- C#实验2.4
- C# 中const和readonly的区别
- 2016年c#:猜数字
- C#设备处理类操作
- 猜数字
- C#字符串操作
- C#语音录制
- (c#vs2008)@page命令属性详解
- C#中的线程二(BeginInvoke和Invoke)
- C#中的线程一(委托中的异步)
- C#比较dynamic和Dictionary性能
- C# 面向对象三大特性:封装、继承、多态
- C#控件随着窗口大小变化而自动变化
- C# Activator.CreateInstance()方法使用
- C#操作注册表