C++获取zip文件列表 // ZipFile.h #ifndef ZIPFILE_H#define ZIPFILE_H#include <string>#include <vector>#define ZIP_O……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2889浏览 1818个赞
正则表达式c语言经典实现/* * test.c * * Created on: 2012-12-4 * Author: Administrator */#include <stdio.h>int matchhere(char *,char *);int matchstar(int c,char *regexp,c……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1991浏览 1421个赞
一个简单的C语言随机数生成器int random(int start,int end){ int h; float k; h=(int)malloc(sizeof(int)); h=h%10000; k=((float)h)/10000; k=start+(end-start)*k; return k;}/** end of http……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3330浏览 1099个赞
C语言设计的简单的随机数字游戏,猜数字的游戏,只能在windows下运行/********************************************************************************************| C O M M E N T……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2442浏览 145个赞
C语言最大公约数和最小公倍数算法实现#include <iostream>#include <cstdio>#define MAX(a,b) (a > b ? a : b)template <class T>T gcd(T a, T b){ return a > b ? (b == 0 ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3354浏览 2699个赞
克努特 – 莫里斯 – 普拉特算法的C语言实现/* Copyright 2011 Shao-Chuan Wang <shaochuan.wang AT gmail.com> Permission is hereby granted, free of charge, to any person obtai……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2255浏览 2782个赞
C语言位操作代码片段/* Copyright 2011 Shao-Chuan Wang <shaochuan.wang AT gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this s……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2311浏览 515个赞
C语言[二分图最大匹配] 匈牙利算法const int INF = 0x3f3f3f3f; const int MAXN=510;int uN,vN;//u,v数目int g[MAXN][MAXN];//构图int link[MAXN]; //link[v]=u表示右边对左边的匹配bool used[MAXN];//是否访问过bool ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1519浏览 2267个赞
C++数组实现二叉树遍历来源:http://blog.csdn.net/fx397993401/article/details/6271686# includestruct node{ int l,r;};struct node tree[100];int path[100];int ans;void init(){ i……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1525浏览 2791个赞
利用UIImageView加载一序列的图像,可以实现动态图像的效果。 感谢开发者@龙龙酱丶 提供代码片段NSMutableArray * images = [NSMutableArray arrayWithCapacity:6];for (int i = 1; i <= 6; i++) { NSString * imageName =……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1884浏览 1768个赞
Objective C判断设备当前的方向UIDevice *device = [UIDevice currentDevice];switch (device.orientation;) { case UIDeviceOrientationFaceUp: NSLog(@"螢幕朝上平躺"……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2207浏览 846个赞
注意保存图片引用的images不能是autorelease的- (void) saveImagesToPhotosAlbum:(NSMutableSet *)images { if (images.count == 0) { [images release]; return; } ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1825浏览 648个赞
iOS自带的照相机功能拍照之后,可以继续保留在拍照界面- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2739浏览 2466个赞
objective C判断一个字符串 是否包含另外一个字符串+(BOOL)stringContentString:(NSString *)motherString subString:(NSString *)sonString{ if ([motherString rangeOfString:sonString].location!=NSNot……继续阅读 » 水墨上仙 5年前 (2021-03-14) 4573浏览 2227个赞
objective c 将字符转换为键盘码的代码- (int)keyCodeForCharacter: (NSString*)character { if(![character length]) return -1; char code; BOOL shift, alt; if(Ascii2Virtual( ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1443浏览 1124个赞
objective C实现iPhone图标的水晶立体效果- (void)viewDidLoad { [super viewDidLoad]; UIGraphicsBeginImageContext(icon.bounds.size); CGContextRef ctx = UIGraphicsGetCurrentContext(……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2323浏览 613个赞
objective C实现圆角效果UIColor *color = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:0];[aImage setBackgroundColor:color]; //设置背景透明/******设置图片圆角begin*******/aImage.layer.m……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2518浏览 2450个赞
题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点,只调整指针的指向。   10  / /  6  14 /&……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2501浏览 1661个赞
C++多进程英文单词统计/* * * Author : shenghan , UESTC * * Time : 2012-11-02 * * Function : A word frequency statistics tool, usage wordscan scan_dir results * */#in……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3177浏览 739个赞
C#接口interface使用范例using System;//example of interfacespublic class Animals{//simple interfaceinterface IAnimal { void Breathes();}//interfaces can inherent from other in……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2244浏览 873个赞
C#使用XmlDocument通过XPath获取单个节点的值public static Survey GetSurvey(string groupName, string surveyName) { XmlDocument xmlSurveys = new XmlDocument(); xmlSurveys.Load……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2779浏览 836个赞
C#通过xpath从dom获取文本值using System.Xml; using System.Xml.XPath; ... //create initial DOM XmlDocument xmlDocument = new XmlDocument(); /// <TextDefinitions> /……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3203浏览 1209个赞
C# AddRange为数组添加多个元素ArrayList ab = new ArrayList();ab.Add("a"); //old fashioned wayab.Add("b");ArrayList abcd = new ArrayList();abcd.AddRange(new string[……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2683浏览 206个赞
C# spilit函数的StringSplitOptions.RemoveEmptyEntries设置清除数组里的空值using System;class Animals {private static void Main() { string[] animals = "monkey,kangaroo,,,wallaby,……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1517浏览 2319个赞
C#通过Get方式调用Web Service返回一个字符串,可以带参数访问public string getServiceResult(string serviceUrl) { HttpWebRequest HttpWReq; HttpWebResponse HttpWResp; HttpWReq = (HttpWebRequest)WebReq……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3187浏览 2761个赞
C语言只用一行代码交换两个整型变量的值,本人在vc++2010下测试这个代码不对,最后返回的结果是a=10,b=10,在C#下面测试这个代码,返回的结果更离谱,居然是a=20,b=20,都没有交换,不知道为什么。#include <stdio.h> int main(){ int a=10,b=20; printf(……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2570浏览 1641个赞
C#字符串转换成字节(byte)数组public static byte[] ToByteArray(string str){ System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); return encoding.GetBytes(str);}……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2623浏览 1132个赞
本代码列举了一些字符串格式化的方法,非常实用int MySalary = 123456; String.Format( "{0:C}", MySalary ); // $123,456.00String.Format( "{0:D}", MySalary ); // 123456String.Format……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3162浏览 1070个赞
这段代码演示了C#中如何使用Gmail账号发送邮件using System.Web.Mail;using System;public class MailSender{ public static bool SendEmail( string pGmailEmail, string pGmailPassw……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1844浏览 197个赞
有时候我们知道类的名字,希望根据类名来实例化一个类,下面的代码可以帮你完成/// <summary> /// 根据任务返回处理该任务的对象 /// </summary> /// <param name="task">具体任务</param>……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1806浏览 1263个赞
C#共享文件夹的代码片段System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = " /c ne……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1869浏览 813个赞
C#读写xml文件的简单范例 //读配置文件 XmlDocument doc = new XmlDocument(); doc.Load("blog.xml"); XmlNode url = doc.SelectSingleNode(&qu……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1662浏览 972个赞
给定两个时间,计算时间差,输出类似于“相差10天5小时10分28秒”的格式DateTime dtone = Convert.ToDateTime("2007-1-1 05:32:22");DateTime dtwo = Convert.ToDateTime("2007-1-1 04:20:15");TimeS……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2952浏览 1074个赞
//网站配置文件如下 //要获得数据库文件的物理路径可以通过下面的代码获得:string connStr = ConfigurationManager.AppSettings["connStr"].ToString() + HttpContext.Current.Request.PhysicalApplicat……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1867浏览 1895个赞
1、可以指定文字字体、大小和颜色(注:指定的文字在WEB服务器上需要有该字库); 2、可以加文字阴影; 3、可以指定文字的透明度; 4、可以指定背景图片或背景颜色; 5、可以指定生成的图片大小(宽度与高度); 6、可以指定文字的位置(左边距和上边距); 7、当用户设定的文字字号太大,能自动调整文字大小使之能适应生成图片的大小。 using Sy……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2633浏览 2557个赞
C#可以通过File对象的ReadAllText方法快速读取文本文件File.ReadAllText("c://abc.txt", Encoding.Default);……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3195浏览 1536个赞
C#可以通过调用webBrowser控件实现表单的自动填充,包括下拉列表的自动选择HtmlDocument doc = webBrowser1.Document;HtmlElement el = doc.GetElementById("下拉列表框的ID");el.SetAttribute("selectedIndex&……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2178浏览 1230个赞
在Windows Form的开发中,我们经常要把应用程序最小化到系统托盘,.net可以很方便的实现,只需要在主窗体上添加一个notifyIcon控件,然后调用下面的代码片段即可: private void Form1_SizeChanged(object sender, EventArgs e) { ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2188浏览 638个赞
本代码片段演示了C#中字符串格式化函数string.Format的使用的方法string sr1 = "75271.com";string sr2 = "脚本分享网";string ss = string.Format("本站域名是:{0},站名是:{1},欢迎光临", sr1, sr2)……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2406浏览 994个赞
本代码片段演示了使用冒泡法,插入排序法,选择排序法,希尔排序法,快速排序法对C#数组进行排序,是用C#学习数据结构的好代码片段 using System; namespace DataStruct { public class Sorter { /// <summary> ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1591浏览 1003个赞
这段代码可以抓取指定的url的网络图片,并保存到本地 public Bitmap Get_img() { Bitmap img = null; HttpWebRequest req; HttpWebResponse res = null; ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1860浏览 2300个赞
C#中计算字符串长度,一个中文算两个字符int len1 = System.Text.Encoding.Default.GetBytes("aaa").Length; //结果为 3int len2 = System.Text.Encoding.Default.GetBytes("张三丰").Length; /……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1787浏览 2851个赞
这段代码从控制台接收一个字符串,然后判断该字符串是否可以被转换成整型,用到int.TryParsestring i = Console.ReadLine(); int a=0; if (int.TryParse(i, out a) == false) //判断是否可以转换为整型 {……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2015浏览 550个赞
这段代码是一个IIS操作类,可以最IIS进行站点的添加、删除、修改等操作//IISHelper.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;us……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2820浏览 1929个赞
C# 获得当前运行程序所在的目录using System;using System.IO; class DirectoryCurrent{ public static void Main() { Console.WriteLine ("Current directory: \"{0}\""……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3244浏览 2420个赞