摘要: static int Sqrt1(int num) { if (num < 0) { throw new Exception(num + " doesn't have square root."); } if (num == 1) { return num; } int low = 0; int high = num; ... 阅读全文
posted @ 2012-02-10 07:44 Ligeance 阅读(1047) 评论(0) 推荐(0) 编辑
摘要: static int[] MergeTwoArray(int[] intArr1, int[] intArr2) { if (intArr1 == null || intArr2 == null || intArr1.Length == 0 || intArr2.Length == 0) { throw new Exception("Input cann't be null."); } for (int i = 0; i < intArr1.Len... 阅读全文
posted @ 2012-02-06 09:27 Ligeance 阅读(647) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ReverseSentence{ class Program { static string ReverseSentence(string str) { if (str == null || str == string.Empty) { throw new Exception("input strin... 阅读全文
posted @ 2011-12-16 15:42 Ligeance 阅读(535) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace LinkedList{ public interface IListDS<T> { int GetLength(); void Clear(); bool IsEmpty(); void Append(T item); void Insert(T item, int i); T Delete(int i); ... 阅读全文
posted @ 2011-10-18 14:17 Ligeance 阅读(1560) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace SequenceList{ public interface IListDS<T> { int GetLength(); void Clear(); bool IsEmpty(); void Append(T item); void Insert(T item, int i); T Delete(int i); ... 阅读全文
posted @ 2011-09-30 11:51 Ligeance 阅读(289) 评论(0) 推荐(0) 编辑
摘要: View Code static void FindTwoMins(int[] intArr, ref int firstMin, ref int secondMin) { if (intArr == null || intArr.Length <2) { throw new Exception("Input array can't be empty or less than 2"); } if (intArr[0]> intArr[1]) ... 阅读全文
posted @ 2011-09-21 15:58 Ligeance 阅读(742) 评论(0) 推荐(0) 编辑
摘要: static string ReplaceChar(string str, char chr1, char chr2) { if (str == null || str == string.Empty) { throw new Exception("String input can not be null"); } string result = ""; for (int i = 0; i < str.Length; i++)... 阅读全文
posted @ 2011-09-21 15:34 Ligeance 阅读(11209) 评论(0) 推荐(0) 编辑
摘要: static string ReverseString(string str) { if (str == null || str.Length <= 1) { return str; } string result = ""; for (int i = str.Length - 1; i >= 0; i--) { result += str[i]; } ... 阅读全文
posted @ 2011-09-21 15:25 Ligeance 阅读(346) 评论(0) 推荐(0) 编辑