摘要: 循环数组,通过比较前一个与后一个数的大小,将小的前移,不断地将小的数向前冒;例子:class B_冒泡算法_BubbleSort { static void Main() { List<int> myList = new List<int> { 15, 6, 22, 18, 9, 8, 22, 999, 33, 49, 17, 66, 77, 55 }; Console.WriteLine("排序前的数据"); for (int i = 0; i < myList.Count; i++) { Console.Write(myList[i] + 阅读全文
posted @ 2011-12-13 14:52 yanghongbo 阅读(136) 评论(0) 推荐(0)
摘要: 思想:找一个参照数,将小于该数的放到左边,大于该数的放到右边,分成两部分,然后每部分再不断地递归,直到排好序。网上的例子:class 二分法 { static void Main(string[] args) { int[] a = { 1, 6, 4, 3, 8, 5, 21, 9, 31, 81, 101, 55, 62, 151, 7, 2, 10 }; quicksort(a, 0, a.Length - 1); for (int i = 0; i < a.Length; i++) { Console.WriteLine(a[i]); } Console.Read(); } st 阅读全文
posted @ 2011-12-13 14:34 yanghongbo 阅读(129) 评论(0) 推荐(0)
摘要: 一、概念:通过参数化类型来实现在同一份代码上操作多种数据类型。利用“参数化类型”将类型抽象化,从而实现灵活的复用。二、例子代码:classProgram{staticvoidMain(string[] args){intobj = 2;Test<int> test =newTest<int>(obj);Console.WriteLine("int:"+ test.obj);stringobj2 ="hello world";Test<string> test1 =newTest<string>(obj2); 阅读全文
posted @ 2011-12-13 10:44 yanghongbo 阅读(164) 评论(0) 推荐(0)
摘要: 一、集合:http://www.cnblogs.com/wf225/archive/2008/01/14/1037788.html二、泛型:http://www.cnblogs.com/jimmyzhang/archive/2008/12/17/1356727.htmlhttp://www.cnblogs.com/hjf1223/archive/2005/08/25/222970.htmlhttp://www.cnblogs.com/thcjp/archive/2006/08/27/487550.html 阅读全文
posted @ 2011-12-13 00:49 yanghongbo 阅读(105) 评论(0) 推荐(0)