摘要: View Code static int FindMaxSum(int[] intArr) { int sum = intArr[0]; int max = intArr[0]; for (int i = 1; i < intArr.Length; i++) { if (sum<=0) { sum = intArr[i]; } ... 阅读全文
posted @ 2012-11-07 15:23 Ligeance 阅读(439) 评论(0) 推荐(0) 编辑
摘要: static char FirstUniqueChar(string str) { if (str== null|| str.Length == 0) { throw new Exception("Input can't be empty"); } char[] chrArr = str.ToCharArray(); Hashtable ht = new Hashtable(); for (int i =... 阅读全文
posted @ 2012-10-25 14:40 Ligeance 阅读(328) 评论(0) 推荐(0) 编辑
摘要: static int FindMax(int[][] array) { int max = -1; if (array == null || array.Length == 0) { return max; } for (int i = 0; i < array.Length; i++) { if (array[i] != null) { ... 阅读全文
posted @ 2012-03-17 07:05 Ligeance 阅读(3580) 评论(0) 推荐(0) 编辑
摘要: static int FindNumber(int[] array, int num) { int result = -1; if (array == null) { return result; } for (int i = 0; i < array.Length - 1; i++) { if (array[i] > array[i + 1]) ... 阅读全文
posted @ 2012-03-14 15:17 Ligeance 阅读(2935) 评论(0) 推荐(0) 编辑
摘要: static void InsertSort(int[] input) { if (input == null || input.Length == 0) { throw new Exception("input can't be empty."); } for (int i = 1; i < input.Length; i++) { if (input[i] < input[i - 1]) ... 阅读全文
posted @ 2012-03-14 15:02 Ligeance 阅读(176) 评论(0) 推荐(0) 编辑
摘要: static StringCollection Permutations(string input) { if (input == null) { throw new Exception("input can't be null"); } StringCollection results = new StringCollection(); char firstChar = ' '; string rema... 阅读全文
posted @ 2012-03-12 14:18 Ligeance 阅读(227) 评论(0) 推荐(0) 编辑
摘要: public interface IStack<T> { int GetLength(); bool IsEmpty(); bool IsFull(); void Clear(); void Push(T item); T Pop(); T GetTop(); } public class Stack<T> : IStack<T> { private int size; private T[] data; private i... 阅读全文
posted @ 2012-03-12 13:40 Ligeance 阅读(291) 评论(1) 推荐(1) 编辑
摘要: 求一个方法,能概率性输出 A 70%, B 20%, C 6%, D 3%, E 1% static char Output() { Random rnd = new Random(); int i = rnd.Next(1, 100); if (i<=70) { return 'A'; } if (i>70 && i<=90) { return 'B';... 阅读全文
posted @ 2012-03-12 12:46 Ligeance 阅读(1461) 评论(1) 推荐(0) 编辑
摘要: 假设有6个小朋友,编号为1,2,3,4,5,6。 从1数到3,然后把第3个小朋友去除,再从1数到3,把第6个小朋友去除,再从1数到3, 把第4个小朋友去除,求剩下的最后一个小朋友。 static int Func(int[] array, int count) { if (array == null || array.Length== 0 || count <1) { throw new Exception("array or count can't be empty or less than ... 阅读全文
posted @ 2012-03-12 12:09 Ligeance 阅读(247) 评论(2) 推荐(0) 编辑
摘要: public class Rectangle { public int x1; public int y1; public int x2; public int y2; public Rectangle(int x1, int y1, int x2, int y2) { this.x1 = x1; this.y1 = y1; this.x2 = ... 阅读全文
posted @ 2012-02-21 17:13 Ligeance 阅读(1241) 评论(0) 推荐(0) 编辑