冒泡排序委托
来源:互联网 发布:java实现runnable接口 编辑:程序博客网 时间:2024/06/04 21:01
class Program
{
public delegate bool CompHander(int first, int sencend);
static void Main(string[] args)
{
int[] items = { 12,232,22,4353,323423,11,24,1,4,343};
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.WriteLine();
//BulletSort(ref items, Number);
BulletSort(ref items, AlpCompare);
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.ReadKey();
}
public static void BulletSort(ref int[] items,CompHander ComparisonMethod)
{
int temp;
if (items == null)
{
return;
}
for (int i = 0; i < items.Length; i++)
{
for (int j = i; j >=1; j--)
{
if (ComparisonMethod(items[j-1],items[j]))
{
temp = items[j - 1];
items[j - 1] = items[j];
items[j] = temp;
}
}
}
}
public static bool Number(int first, int sencend)
{
return first > sencend;
}
public static bool AlpCompare(int first, int sencend)
{
int comnub;
comnub = (first.ToString().CompareTo(sencend.ToString()));
return comnub > 0;
}
}
{
public delegate bool CompHander(int first, int sencend);
static void Main(string[] args)
{
int[] items = { 12,232,22,4353,323423,11,24,1,4,343};
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.WriteLine();
//BulletSort(ref items, Number);
BulletSort(ref items, AlpCompare);
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.ReadKey();
}
public static void BulletSort(ref int[] items,CompHander ComparisonMethod)
{
int temp;
if (items == null)
{
return;
}
for (int i = 0; i < items.Length; i++)
{
for (int j = i; j >=1; j--)
{
if (ComparisonMethod(items[j-1],items[j]))
{
temp = items[j - 1];
items[j - 1] = items[j];
items[j] = temp;
}
}
}
}
public static bool Number(int first, int sencend)
{
return first > sencend;
}
public static bool AlpCompare(int first, int sencend)
{
int comnub;
comnub = (first.ToString().CompareTo(sencend.ToString()));
return comnub > 0;
}
}
0 0
- 冒泡排序委托
- C#之冒泡排序(委托)
- C#中的委托版的冒泡排序
- 委托(1. 冒泡排序自定义类型)
- 委托、冒泡排序、lambda表达式、事件
- C#中使用委托对字符串进行冒泡排序案例
- 委托的应用——通用冒泡排序
- javascript事件委托(冒泡)
- C#委托冒泡
- 委托排序
- Unity之C#——利用泛型与委托拓展冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- 冒泡排序
- SAP FI模块-记账凭证FB01的BAPI
- 小白带你玩VMware(一)虚拟机的创建
- 程序员到项目经理:从内而外的提升(比较全面的介绍)
- 调用scrollViewDidScroll,点击返回键崩溃
- javascript高级程序设计 5.5.3作为值得函数
- 冒泡排序委托
- JS复制到剪贴板兼容FF
- 智能指针的用法以及根据前序遍历生成树
- 工具——使用SVN进行项目版本管理
- 你用过栅格系统吗?如果使用过,你最喜欢哪种?
- Jboss配置远程调试
- 路由器专业术语
- ios算法总结(非完整版)
- Web Server 架构浅谈-Simple Multiple Threaded Achitecture