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……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1680浏览 2742个赞
利用UIImageView加载一序列的图像,可以实现动态图像的效果。 感谢开发者@龙龙酱丶 提供代码片段NSMutableArray * images = [NSMutableArray arrayWithCapacity:6];for (int i = 1; i <= 6; i++) { NSString * imageName =……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2459浏览 1787个赞
Objective C判断设备当前的方向UIDevice *device = [UIDevice currentDevice];switch (device.orientation;) { case UIDeviceOrientationFaceUp: NSLog(@"螢幕朝上平躺"……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3468浏览 2322个赞
注意保存图片引用的images不能是autorelease的- (void) saveImagesToPhotosAlbum:(NSMutableSet *)images { if (images.count == 0) { [images release]; return; } ……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2336浏览 565个赞
iOS自带的照相机功能拍照之后,可以继续保留在拍照界面- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3040浏览 750个赞
objective C判断一个字符串 是否包含另外一个字符串+(BOOL)stringContentString:(NSString *)motherString subString:(NSString *)sonString{ if ([motherString rangeOfString:sonString].location!=NSNot……继续阅读 » 水墨上仙 6年前 (2021-03-14) 4682浏览 2246个赞
objective c 将字符转换为键盘码的代码- (int)keyCodeForCharacter: (NSString*)character { if(![character length]) return -1; char code; BOOL shift, alt; if(Ascii2Virtual( ……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2016浏览 2439个赞
objective C实现iPhone图标的水晶立体效果- (void)viewDidLoad { [super viewDidLoad]; UIGraphicsBeginImageContext(icon.bounds.size); CGContextRef ctx = UIGraphicsGetCurrentContext(……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2596浏览 2639个赞
objective C实现圆角效果UIColor *color = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:0];[aImage setBackgroundColor:color]; //设置背景透明/******设置图片圆角begin*******/aImage.layer.m……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1755浏览 304个赞
题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点,只调整指针的指向。   10  / /  6  14 /&……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1931浏览 1224个赞
C++多进程英文单词统计/* * * Author : shenghan , UESTC * * Time : 2012-11-02 * * Function : A word frequency statistics tool, usage wordscan scan_dir results * */#in……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2097浏览 699个赞
C#接口interface使用范例using System;//example of interfacespublic class Animals{//simple interfaceinterface IAnimal { void Breathes();}//interfaces can inherent from other in……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1675浏览 2007个赞
C#使用XmlDocument通过XPath获取单个节点的值public static Survey GetSurvey(string groupName, string surveyName) { XmlDocument xmlSurveys = new XmlDocument(); xmlSurveys.Load……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2852浏览 2381个赞
C#通过xpath从dom获取文本值using System.Xml; using System.Xml.XPath; ... //create initial DOM XmlDocument xmlDocument = new XmlDocument(); /// <TextDefinitions> /……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1609浏览 2912个赞
C# AddRange为数组添加多个元素ArrayList ab = new ArrayList();ab.Add("a"); //old fashioned wayab.Add("b");ArrayList abcd = new ArrayList();abcd.AddRange(new string[……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2428浏览 1286个赞
C# spilit函数的StringSplitOptions.RemoveEmptyEntries设置清除数组里的空值using System;class Animals {private static void Main() { string[] animals = "monkey,kangaroo,,,wallaby,……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2095浏览 1421个赞
C#通过Get方式调用Web Service返回一个字符串,可以带参数访问public string getServiceResult(string serviceUrl) { HttpWebRequest HttpWReq; HttpWebResponse HttpWResp; HttpWReq = (HttpWebRequest)WebReq……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3280浏览 891个赞
C语言只用一行代码交换两个整型变量的值,本人在vc++2010下测试这个代码不对,最后返回的结果是a=10,b=10,在C#下面测试这个代码,返回的结果更离谱,居然是a=20,b=20,都没有交换,不知道为什么。#include <stdio.h> int main(){ int a=10,b=20; printf(……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3343浏览 1113个赞
C#字符串转换成字节(byte)数组public static byte[] ToByteArray(string str){ System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); return encoding.GetBytes(str);}……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3098浏览 1328个赞
本代码列举了一些字符串格式化的方法,非常实用int MySalary = 123456; String.Format( "{0:C}", MySalary ); // $123,456.00String.Format( "{0:D}", MySalary ); // 123456String.Format……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2596浏览 2009个赞
这段代码演示了C#中如何使用Gmail账号发送邮件using System.Web.Mail;using System;public class MailSender{ public static bool SendEmail( string pGmailEmail, string pGmailPassw……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2332浏览 2825个赞
有时候我们知道类的名字,希望根据类名来实例化一个类,下面的代码可以帮你完成/// <summary> /// 根据任务返回处理该任务的对象 /// </summary> /// <param name="task">具体任务</param>……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3040浏览 139个赞
C#共享文件夹的代码片段System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = " /c ne……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1996浏览 2237个赞
C#读写xml文件的简单范例 //读配置文件 XmlDocument doc = new XmlDocument(); doc.Load("blog.xml"); XmlNode url = doc.SelectSingleNode(&qu……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1764浏览 1802个赞
给定两个时间,计算时间差,输出类似于“相差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……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1620浏览 1806个赞
//网站配置文件如下 //要获得数据库文件的物理路径可以通过下面的代码获得:string connStr = ConfigurationManager.AppSettings["connStr"].ToString() + HttpContext.Current.Request.PhysicalApplicat……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3603浏览 2954个赞
1、可以指定文字字体、大小和颜色(注:指定的文字在WEB服务器上需要有该字库); 2、可以加文字阴影; 3、可以指定文字的透明度; 4、可以指定背景图片或背景颜色; 5、可以指定生成的图片大小(宽度与高度); 6、可以指定文字的位置(左边距和上边距); 7、当用户设定的文字字号太大,能自动调整文字大小使之能适应生成图片的大小。 using Sy……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1768浏览 1198个赞
C#可以通过File对象的ReadAllText方法快速读取文本文件File.ReadAllText("c://abc.txt", Encoding.Default);……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2168浏览 856个赞
C#可以通过调用webBrowser控件实现表单的自动填充,包括下拉列表的自动选择HtmlDocument doc = webBrowser1.Document;HtmlElement el = doc.GetElementById("下拉列表框的ID");el.SetAttribute("selectedIndex&……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2096浏览 202个赞
在Windows Form的开发中,我们经常要把应用程序最小化到系统托盘,.net可以很方便的实现,只需要在主窗体上添加一个notifyIcon控件,然后调用下面的代码片段即可: private void Form1_SizeChanged(object sender, EventArgs e) { ……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1666浏览 231个赞
本代码片段演示了C#中字符串格式化函数string.Format的使用的方法string sr1 = "75271.com";string sr2 = "脚本分享网";string ss = string.Format("本站域名是:{0},站名是:{1},欢迎光临", sr1, sr2)……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3217浏览 1076个赞
本代码片段演示了使用冒泡法,插入排序法,选择排序法,希尔排序法,快速排序法对C#数组进行排序,是用C#学习数据结构的好代码片段 using System; namespace DataStruct { public class Sorter { /// <summary> ……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2533浏览 609个赞
这段代码可以抓取指定的url的网络图片,并保存到本地 public Bitmap Get_img() { Bitmap img = null; HttpWebRequest req; HttpWebResponse res = null; ……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3233浏览 2624个赞
C#中计算字符串长度,一个中文算两个字符int len1 = System.Text.Encoding.Default.GetBytes("aaa").Length; //结果为 3int len2 = System.Text.Encoding.Default.GetBytes("张三丰").Length; /……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2062浏览 888个赞
这段代码从控制台接收一个字符串,然后判断该字符串是否可以被转换成整型,用到int.TryParsestring i = Console.ReadLine(); int a=0; if (int.TryParse(i, out a) == false) //判断是否可以转换为整型 {……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2971浏览 2030个赞
这段代码是一个IIS操作类,可以最IIS进行站点的添加、删除、修改等操作//IISHelper.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;us……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1823浏览 1632个赞
C# 获得当前运行程序所在的目录using System;using System.IO; class DirectoryCurrent{ public static void Main() { Console.WriteLine ("Current directory: \"{0}\""……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1747浏览 2700个赞
C# 获得目录创建时间,在这段代码中先创建一个目录,获取创建时间后,将目录删除using System;using System.IO; class DirectoryCreationTime{ public static void Main() { string directoryString = ……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2810浏览 2754个赞
C#创建和删除目录using System;using System.IO; class DirectoryCreation{ public static void Main() { string directoryString = Directory.GetCurrentDirectory() +……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2667浏览 1661个赞
C#清除IE浏览器缓存,IE的临时文件夹using System.IO; ...void clearIECache(){ ClearFolder (new DirectoryInfo (Environment.GetFolderPath (Environment.SpecialFolder.InternetCache)));}……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2312浏览 1340个赞
C# 创建Group Object in Active Directoryusing System.DirectoryServices;using System.Reflection; public class ADGroup{ private String ADGRPOUP = "group"; // ……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3466浏览 1586个赞
using System.Data;using System.Data.SqlClient;…// Substitute your connection string below in conxString String conxString = “Data Source=MYSERVER; Integrated Securit……继续阅读 » 水墨上仙 6年前 (2021-03-14) 2767浏览 1132个赞
C#检测网络驱动器的剩余磁盘空间using System;using System.Management; class NetworkSpace{ static void Main(string[] args) { SelectQuery query = new SelectQuery( "select……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1968浏览 1972个赞
C#检测光驱里的光盘是否已经加载using System;using System.Management; class App{ public static void Main() { SelectQuery query = new SelectQuery( "select * from win32_logicaldi……继续阅读 » 水墨上仙 6年前 (2021-03-14) 1967浏览 888个赞
这段代码演示了C#如何通过修改AssemblyInfo.cs文件实现自动版本号// Modify the AssemblyVersion line in the // "AssemblyInfo.cs" file: // Add a "*" to the section you want to increa……继续阅读 » 水墨上仙 6年前 (2021-03-14) 3508浏览 2980个赞