C# 实现堆排序算法代码 1. 什么是堆?可以想像成一个二叉树,对于每一个结点,如果父结点比左右孩子都大叫大顶堆,如果比左右孩子小叫小顶堆。堆不一定要用树来表示,也可以用普通的数组来表示,如果数组索引从1开始,那么索引为i的结点的左右孩子的索引分别为2i和2i+1。2.……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1609浏览 1644个赞
在软件设计相关领域,“堆(Heap)”的概念主要涉及到两个方面:一种是数据结构,逻辑上是一颗完全二叉树,存储上是一个数组对象(二叉堆)。另一种是垃圾收集存储区,是软件系统可以编程的内存区域。本文所说的堆指的是前者,另外,这篇文章中堆中元素的值均以整形为例堆排序的时间复杂度是O(nlog2n),与快速排序达到相同的时间复杂度. 但是在实际应用中,我们往往采用快……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1947浏览 1184个赞
这是一个C#实现的屏幕抓取程序,可以抓取整个屏幕保存为指定格式的图片,并且保存当前控制台缓存到文本using System;using System.Collections.Generic;using System.ComponentModel;using System.Diagnostics;using System.Drawing;usin……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1692浏览 1408个赞
C#检测指定的URL网址是否可用,相当于一个针对网址的ping操作,非常实用using System;using System.Media;using System.Net;using System.Threading;namespace RobvanderWoude{ class PingSite { static bool beep……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1922浏览 1422个赞
此代码可以返回指定PDF文件有多少页using System;using System.IO;using System.Text.RegularExpressions;using System.Windows.Forms;namespace RobvanderWoude{ class PDFPageCount { static int ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2745浏览 744个赞
C#从windows剪贴板获取并显示文本内容using System;using System.Windows.Forms;namespace RobvanderWoude{ class Paste { [STAThread] static int Main( string[] args ) { if ( args.Lengt……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3024浏览 2128个赞
这段代码可以在指定的目录创建一个字节为0的临时文件using System;using System.IO;namespace RobvandeWoude{ class NewTempFile { static int Main( string[] args ) { if ( args.Length > 0 ) { ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3127浏览 491个赞
C#代码将指定目录的所有文件名转换成小写using System;using System.IO;using System.Linq;namespace RobvanderWoude{ class LoCase { static int Main( string[] args ) { string dir = string.Em……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1343浏览 395个赞
C#控制台列出当前所有可用的打印机列表// The initial C# code for the WMI query was generated by WMI Code Generator, Version 5.00, http://www.robvanderwoude.com/wmigen.phpusing System;using System……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2455浏览 583个赞
C#列出所有物理网络适配器using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Management;using System.Text;namespace RobvanderWoude{ ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1876浏览 1542个赞
C#返回当前系统所有可用驱动器符号// The initial C# code for the "plain" WMI query was generated by// WMI Code Generator, Version 5.00, http://www.robvanderwoude.com/wmigen.phpusing S……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2667浏览 1484个赞
C#判断指定分区是否是ntfs格式using System;using System.IO;namespace RobvanderWoude{ class IsNTFS { public static int Main( string[] args ) { try { if ( args.Length == 0 )……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1483浏览 2037个赞
C#返回指定驱动器是否是Fat分区格式using System;using System.IO;namespace RobvanderWoude{ class IsFAT { public static int Main( string[] args ) { try { if ( args.Length == 0 )……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1584浏览 445个赞
C#判断当前系统是32位还是64位// The initial C# code for the "plain" WMI query was generated by WMI Code Generator, Version 5.00, http://www.robvanderwoude.com/wmigen.phpusing Syst……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2531浏览 255个赞
C#隐藏控制台的键盘输入using System;namespace RobvanderWoude{ class HideInput { static int Main( string[] args ) { try { bool clearscreen = false; if ( args.Length >……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1664浏览 1765个赞
C#获得父进程PID编号的完整源代码using System;using System.Diagnostics;namespace RobvanderWoude{ class GetMyPID { static int Main( string[] args ) { #region Command Line Parsing ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1750浏览 1348个赞
C#实现的FastPing代码,知己开发一个ping的工具using System;using System.Net.NetworkInformation;namespace RobvanderWoude{ class FastPing { static int Main( string[] args ) { try { ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3172浏览 2689个赞
C#获得本机可用驱动器编号列表using System;using System.Collections.Generic;using System.IO;namespace RobvanderWoude{ class Drives { static int Main( string[] args ) { bool showuse……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2219浏览 2335个赞
C#编写的一个简单的命令行计算器代码using System;using System.CodeDom.Compiler;using System.Globalization;using System.Reflection;using System.Threading;namespace RobvanderWoude{ class ClCa……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2618浏览 516个赞
一个自定义Sql Server字符串分割函数split,类似C#里的split函数,功能虽然不是很强大,应付一般的问题足矣 函数定义Create function [dbo].[split](@SourceSql varchar(max),@StrSeprate varcha……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1367浏览 752个赞
Sql Server定义一个字符串分割函数,类似于C#里的split函数下面的代码使用了临时表作create function f_split(@c varchar(2000),@split varchar(2)) returns @t table(col varchar(20)) as begin……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1805浏览 2923个赞
C#从远程服务器获得本机的上网ipusing System;using System.IO;using System.Net;using System.Text.RegularExpressions;namespace RobvanderWoude{ class WANIP { static int Main( string[] arg……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1737浏览 1593个赞
C#随机设置900-1100毫秒的延迟using System;using System.Threading;///<summary>/// A time delay of 900..1100 milliseconds///</summary>namespace RobvanderWoude{ class WaitA……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2880浏览 981个赞
C#将制定目录的文件名都转换成大写using System;using System.IO;using System.Linq;namespace RobvanderWoude{ class UpCase { static int Main( string[] args ) { string dir = string.Empty……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1578浏览 2280个赞
C#重定向标准输入到标准输出using System;using System.IO;using System.Runtime.InteropServices;namespace RobvanderWoude{ class Tee { static int Main( string[] args ) { #region Comm……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1423浏览 2205个赞
C#读取文件或者字符流的最后几行,类似linux的tail命令using System;using System.Collections.Generic;using System.IO;using System.Runtime.InteropServices;namespace RobvanderWoude{ class Tail { ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2967浏览 369个赞
C#获取指定字符串的MD5和SHA*加密代码using System;using System.Text;using System.Security.Cryptography;namespace StringHash{ class StringHash { static int Main(string[] args) { try……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1999浏览 619个赞
C#读取或者设置ScrollLock状态,允许滚动状态读取或者设置using System;using System.Runtime.InteropServices;using System.Windows.Forms;namespace RobvanderWoude{ public class ScrollLock { [DllImpo……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1487浏览 2164个赞
C#在多行字符串中查找指定信息,类似linux下的grep功能using System;using System.IO;using System.Runtime.InteropServices;using System.Text.RegularExpressions;namespace RobvanderWoude{ class Rx……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2114浏览 201个赞
C# 修改指定文件的最后修改时间的时间戳using System;using System.IO;using System.Linq;namespace RobvanderWoude{ class CloneDate { static int Main( string[] args ) { bool debug = false;……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1656浏览 1285个赞
C# 读取和设置大小写切换键状态可以通过程序查看或者设置当前键盘上的Capslock健的状态是否打开using System;using System.Runtime.InteropServices;using System.Windows.Forms;namespace RobvanderWoude{ public class CapsLoc……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2266浏览 2503个赞
C#返回指定ASCII码的十进制字符using System;namespace RobvanderWoude{ class Asc { static int Main( string[] args ) { if ( args.Length != 1 ) { return WriteError( string.Empt……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1641浏览 1812个赞
在运行时反射是程序检查其所拥有的结构,尤其是类型的一种能力;这是元编程的一种形式。它同时也是造成混淆的重要来源。在这篇文章中将试图明确解释在 Go 中的反射是如何工作的。每个语言的反射模型都不同(同时许多语言根本不支持反射)。不过这篇文章是关于 Go 的,因此接下来的内容“反射”这一词表示“在 Go 中的反射”。转自:http://www.mikespook……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2439浏览 725个赞
使用前请先引用:ThoughtWorks.QRCode.Codecusing ThoughtWorks.QRCode.Codec; //content = "欢迎光临75271.com"; QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2265浏览 2284个赞
背包问题(Knapsack problem)的描述为:给定一组物品,每种物品都有自己的重量和价格,在限定的总重量内,我们如何选择,才能使得物品的总价格最高class Item { public int weigth; public int price; } static int ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2802浏览 219个赞
C#动态规划解决0-1背包问题转自:http://blog.csdn.net/smart819819/article/details/8694272// 利用动态规划解决0-1背包问题using System;using System.Collections.Generic;using System.Linq;using System.Text;……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2276浏览 2759个赞
C#通过QRCode生成二维码public class QRCode { /// <summary> /// 根据ID生成一个二维码 /// /// </summary> /// <param name="cardID">&l……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3206浏览 1537个赞
编辑距离的算法是首先由俄国科学家Levenshtein提出的,故又叫 Levenshtein Distance。一个字符串可以通过增加一个字符,删除一个字符,替换一个字符得到另外一个字符串,假设,我们把从字符串A转换成字符串B,前面3种操作所执行的最少次数称为AB相似度 如 abc adc 度为 1 ababababa babababab 度……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2736浏览 567个赞
C#字符串相似度比较编辑距离算法最先是由俄国科学家Levenshtein提出的,所以这个算法也叫做Levenshtein Distance算法。用最简单的一句话来说明这个算法就是:通过插入、删除、替换方法将字符串A变成字符串B所有的步骤就是算法中提到的编辑距离,最简单的相似度即编辑距离的倒数。代码转自:http://blog.csdn.net/yangzho……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2843浏览 2447个赞
C#通过编辑距离算法实现字符串相似度比较编辑距离:通过插入、删除、替换一个字符(和交换相邻字符)的操作,使得字符串A和字符串B相同,而最少的操作次数就是编辑距离。如字符串abcd和aca的距离是2public class LevenshteinDistance { private static LevenshteinDistanc……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2455浏览 2896个赞
使用OFFICE 的Excel 自动化服务来生成Excel文件的办法,也就是使用Excel提供的Com对象public static void CreateExcel() { for(int i = 0 ; i<1 ; i++) { string staFile = "D:\\test\\x"; ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1719浏览 626个赞
回文:称正读和反读都相同的字符序列为“回文”,如“abba”、“abccba”、12321、123321是“回文”,“abcde”和“ababab”则不是“回文”。//--------------------------算法三:-----------Console.WriteLine("算法3:请输入一个字符串!");string……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2635浏览 1804个赞
回文:称正读和反读都相同的字符序列为“回文”,如“abba”、“abccba”、12321、123321是“回文”,“abcde”和“ababab”则不是“回文”。// ------------------算法二:利用栈先进后出,队列先进先出的特点----------------//abbaConsole.WriteLine("算法2:请输……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2900浏览 644个赞
C#进行回文检测,判断字符串是否是回文回文:称正读和反读都相同的字符序列为“回文”,如“abba”、“abccba”、12321、123321是“回文”,“abcde”和“ababab”则不是“回文”。// --------------- 算法一:根据数组元素----------------------------Console.WriteLine(&……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1700浏览 154个赞
C# 自定义堆栈进行回文检测转自:http://blog.csdn.net/haifengzhilian/article/details/8848477using System; using System.Collections; namespace CStack { class Program { ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1629浏览 320个赞