摘要: 1 #region 2 public static void ToDownload() 3 { 4 string downloadPath = "f:/temp/eclipse-SDK-3.6.1-win32.zip"; 5 string savename = "eclipse-3.6.1.zip"; 6 ToDownloadOrOpen(downloadPath, savename, "attachment"); 7 //ToDownloadOrOp... 阅读全文
posted @ 2012-12-27 18:16 宁静.致远 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 时间格式转换 3 /// </summary> 4 public static void DateTimeToString() 5 { 6 DateTime dt = DateTime.Now; 7 Console.WriteLine(dt); 8 Console.WriteLine(dt.ToString("yyyy-M-dd h:m:ss")); //12小时制 9 C... 阅读全文
posted @ 2012-12-27 18:14 宁静.致远 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 1 public static void Main() 2 { 3 /* 4 * 参数类型分为 in, ref, out 三种,默认为 in。 5 * in 类型在子方法中修改了对应变量后,主方法中的值不会发生改变。 6 * ref 类型在子方法中修改了对应变量后,主方法中的值也会发生改变。 7 * out 主方法中对应的变量不需要初始化。 8 * 9 */10 int a... 阅读全文
posted @ 2012-12-27 18:13 宁静.致远 阅读(227) 评论(0) 推荐(0) 编辑
摘要: View Code 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace ActionDelegate 7 { 8 delegate void OutputInfo(string str,int count); 9 10 class Program11 {12 private static string str = "hello world";13 private stati... 阅读全文
posted @ 2012-12-27 18:09 宁静.致远 阅读(148) 评论(0) 推荐(0) 编辑
摘要: View Code 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.IO; 6 7 namespace Files 8 { 9 class Program 10 { 11 static byte[] byDataValue = new byte[200]; 12 static char[] charDataValue = new char[200]; 13 ... 阅读全文
posted @ 2012-12-27 18:08 宁静.致远 阅读(214) 评论(0) 推荐(0) 编辑
摘要: View Code 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace Sort 7 { 8 class Tree 9 { 10 static void Main(string[] args) 11 { 12 BinarySearchTree nums = new BinarySearchTree(); 13 num... 阅读全文
posted @ 2012-12-27 18:06 宁静.致远 阅读(208) 评论(0) 推荐(0) 编辑
摘要: View Code 1 using System; 2 using System.IO; 3 using System.Net; 4 using System.Text; 5 using System.Security; 6 using System.Threading; 7 using System.Collections.Specialized; 8 using Sort; 9 10 namespace Sort 11 { 12 // <summary> 13 /// 记录下载的字节位置 14 /// </summary> 15 pub... 阅读全文
posted @ 2012-12-27 18:04 宁静.致远 阅读(334) 评论(0) 推荐(0) 编辑
摘要: 1 #region 堆排序 2 /// <summary> 3 /// array是待调整的堆数组 4 /// i是待调整的数组元素的位置,length是数组的长度 5 /// </summary> 6 /// <param name="array"></param> 7 /// <param name="i"></param> 8 /// <param name="nLength"></param> 9 private static vo 阅读全文
posted @ 2012-12-27 18:02 宁静.致远 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 1 #region KMP算法 2 /// <summary> 3 /// KMP算法 4 /// 求一个字符串的回溯函数。 5 /// 约定序列下标从0开始。 6 /// 回溯函数是整数集[0,n-1]到N的映射,n为字符串的长度。 7 /// 回溯函数的定义: 8 /// 设存在非空序列L,i为其合法下标; 9 /// L[i]的前置序列集为:{空集,L中所有以i-1为最后一个元素下标的子序列}10 /// L的前置序列集为... 阅读全文
posted @ 2012-12-27 18:01 宁静.致远 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 动态规划:背包问题 3 /// </summary> 4 private static void MaxVal() 5 { 6 int capacity = 16; //背包负重 7 int[] size = new int[] { 3,4,7,8,9 }; //物品大小 8 int[] values = new int[] { 4,5,10,11,13 }; //物品价值 ... 阅读全文
posted @ 2012-12-27 18:00 宁静.致远 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 希尔排序 3 /// 插入排序改进版本:分区插入 4 /// </summary> 5 /// <param name="list"></param> 6 private static int[] ShellSort(int[] list) 7 { 8 int inc; 9 for (inc = 1; inc <= list.Length / 9; inc = 3 * inc + 1) ;1... 阅读全文
posted @ 2012-12-27 17:59 宁静.致远 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 动态规划:求最大公共子串 3 /// LCS (Longest Common Subsequence) 4 /// </summary> 5 private static string LCS(string str1, string str2) 6 { 7 var d = new int[str1.Length, str2.Length]; 8 var index = 0; 9 ... 阅读全文
posted @ 2012-12-27 17:58 宁静.致远 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 生男生女问题 3 /// 题目:说澳大利亚的父母喜欢女孩,如果生出来的第一个女孩,就不再生了,如果是男孩就继续生, 4 /// 直到生到第一个女孩为止,问若干年后,男女的比例是多少? 5 /// </summary> 6 /// <param name="number"></param> 7 private static void BobyBorn(int number) 8 { 9 int boy... 阅读全文
posted @ 2012-12-27 17:57 宁静.致远 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 上楼梯算法(迭代) 3 /// </summary> 4 /// <param name="n"></param> 5 /// <returns></returns> 6 private static long fib3(int n) 7 { 8 long x = 0, y = 0, z = 1; 9 long w, k;10 11 for (int j = 0; j... 阅读全文
posted @ 2012-12-27 17:56 宁静.致远 阅读(624) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 基数排序 3 /// 原理:首先按个位数进行排序,再以十位数排序 4 /// LSD的排序方式由键值的最右边开始,而MSD则相反,由键值的最左边开始。 5 /// </summary> 6 /// <param name="v"></param> 7 /// <returns></returns> 8 public static int[] RadixSort(int[] v) 9 {10 ... 阅读全文
posted @ 2012-12-27 17:54 宁静.致远 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 归并排序_合并 3 /// </summary> 4 /// <param name="v"></param> 5 /// <param name="first"></param> 6 /// <param name="mid"></param> 7 /// <param name="last"></param> 8 public static int[ 阅读全文
posted @ 2012-12-27 17:53 宁静.致远 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 选择排序 3 /// 原理:每次找出最小的元素排在最前面 4 /// </summary> 5 /// <param name="arr"></param> 6 /// <returns></returns> 7 public static int[] SelectionSort(int[] ary) 8 { 9 int m = 0;10 for (int i = 0; i ... 阅读全文
posted @ 2012-12-27 17:51 宁静.致远 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 快速排序 3 /// 原理:将数组分成两组,前面一组比后面一组小,然后前后两组依次再次划分,直到全部有序 [ref List<int> nums] 4 /// </summary> 5 /// <param name="nums">待排序数组</param> 6 /// <param name="left">数组第一个数下标</param> 7 /// <param name="right">数组 阅读全文
posted @ 2012-12-27 17:50 宁静.致远 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 折半插入排序 3 /// </summary> 4 /// <param name="arr"></param> 5 /// <returns></returns> 6 public static int[] HalfInsertSort(int[] arr) 7 { 8 for (int i = 1; i < arr.Length; i++) 9 {10 i... 阅读全文
posted @ 2012-12-27 17:49 宁静.致远 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 直接插入排序(升序排列) 3 /// 原理:通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入 4 /// </summary> 5 /// <param name="arr"></param> 6 /// <returns></returns> 7 public static int[] InsertSort(int[] arr) 8 { 9 for (int i =... 阅读全文
posted @ 2012-12-27 17:44 宁静.致远 阅读(408) 评论(0) 推荐(0) 编辑