C语言去掉字符串首尾的 空格 换行 回车/*去掉字符串首尾的 \x20 \r \n 字符by sincoder*/void clean_string(char *str){ char *start = str - 1; char *end = str; char *p = str; while(*p) { switch(*p)……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3139浏览 2482个赞
C语言基础:timezone名字显示#include <stdio.h>#include <time.h>int main(void) { tzset(); printf("Current time zone is %s\n", tzname[0]); if (tzname[1]) ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1862浏览 2487个赞
C语言基础:文件拷贝#include <stdio.h>int main(void) { FILE *input, *output; int letter; if ((input = fopen("\\CONFIG.SYS", "r")) == NULL) printf……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2272浏览 1573个赞
C语言变成:磁盘检测代码片段#include <stdio.h>#include <dos.h>#include <malloc.h>void main(void) { struct fatinfo fat; long sector, total_sectors; void *buffer;……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2510浏览 2493个赞
C语言基础:创建文件#include <stdio.h>#include <dos.h>#include <io.h>void main(void) { int handle; if ((handle = creatnew("NEW.DAT", 0)) == -1) ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1678浏览 1199个赞
C语言基础:创建临时文件夹#include <stdio.h>#include <dos.h>#include <io.h>void main(void) { char path[64] = "C:\\TEMP\\"; int handle; if ((handle = ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1354浏览 1359个赞
在N个元素中查找第K大元素,一般比较简单的方法就是先快速排序,然后直接返回array[N – K]或者利用扫描法,每一次扫描都找到当前数组中最大的元素,这个其实就是部分冒泡排序。前一种算法的时间复杂度是O(NlogN),后一种算法的时间复杂度是K*N。当然,这里我们不打算具体讨论以上两种方案,接下来看看其他方法。 &……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3229浏览 1702个赞
C++获取zip文件列表 // ZipFile.h #ifndef ZIPFILE_H#define ZIPFILE_H#include <string>#include <vector>#define ZIP_O……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2543浏览 1398个赞
正则表达式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) 3262浏览 1326个赞
一个简单的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) 1848浏览 2601个赞
C语言设计的简单的随机数字游戏,猜数字的游戏,只能在windows下运行/********************************************************************************************| C O M M E N T……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2988浏览 1542个赞
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) 2983浏览 2626个赞
克努特 – 莫里斯 – 普拉特算法的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) 1463浏览 657个赞
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) 2256浏览 193个赞
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) 2627浏览 2020个赞
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) 3036浏览 693个赞
利用UIImageView加载一序列的图像,可以实现动态图像的效果。 感谢开发者@龙龙酱丶 提供代码片段NSMutableArray * images = [NSMutableArray arrayWithCapacity:6];for (int i = 1; i <= 6; i++) { NSString * imageName =……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1404浏览 1586个赞
Objective C判断设备当前的方向UIDevice *device = [UIDevice currentDevice];switch (device.orientation;) { case UIDeviceOrientationFaceUp: NSLog(@"螢幕朝上平躺"……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2045浏览 2595个赞
注意保存图片引用的images不能是autorelease的- (void) saveImagesToPhotosAlbum:(NSMutableSet *)images { if (images.count == 0) { [images release]; return; } ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2783浏览 1455个赞
iOS自带的照相机功能拍照之后,可以继续保留在拍照界面- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2683浏览 1218个赞
objective C判断一个字符串 是否包含另外一个字符串+(BOOL)stringContentString:(NSString *)motherString subString:(NSString *)sonString{ if ([motherString rangeOfString:sonString].location!=NSNot……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3496浏览 172个赞
objective c 将字符转换为键盘码的代码- (int)keyCodeForCharacter: (NSString*)character { if(![character length]) return -1; char code; BOOL shift, alt; if(Ascii2Virtual( ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2170浏览 855个赞
objective C实现iPhone图标的水晶立体效果- (void)viewDidLoad { [super viewDidLoad]; UIGraphicsBeginImageContext(icon.bounds.size); CGContextRef ctx = UIGraphicsGetCurrentContext(……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3134浏览 1763个赞
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) 1809浏览 1106个赞
题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点,只调整指针的指向。   10  / /  6  14 /&……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1316浏览 1389个赞
C++多进程英文单词统计/* * * Author : shenghan , UESTC * * Time : 2012-11-02 * * Function : A word frequency statistics tool, usage wordscan scan_dir results * */#in……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1599浏览 1796个赞
C#接口interface使用范例using System;//example of interfacespublic class Animals{//simple interfaceinterface IAnimal { void Breathes();}//interfaces can inherent from other in……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2489浏览 1473个赞
C#使用XmlDocument通过XPath获取单个节点的值public static Survey GetSurvey(string groupName, string surveyName) { XmlDocument xmlSurveys = new XmlDocument(); xmlSurveys.Load……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2646浏览 2333个赞
C#通过xpath从dom获取文本值using System.Xml; using System.Xml.XPath; ... //create initial DOM XmlDocument xmlDocument = new XmlDocument(); /// <TextDefinitions> /……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2956浏览 2473个赞
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) 3249浏览 2256个赞
C# spilit函数的StringSplitOptions.RemoveEmptyEntries设置清除数组里的空值using System;class Animals {private static void Main() { string[] animals = "monkey,kangaroo,,,wallaby,……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2636浏览 1017个赞
C#通过Get方式调用Web Service返回一个字符串,可以带参数访问public string getServiceResult(string serviceUrl) { HttpWebRequest HttpWReq; HttpWebResponse HttpWResp; HttpWReq = (HttpWebRequest)WebReq……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1742浏览 2370个赞
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) 1719浏览 2516个赞
C#字符串转换成字节(byte)数组public static byte[] ToByteArray(string str){ System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); return encoding.GetBytes(str);}……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2107浏览 2828个赞
本代码列举了一些字符串格式化的方法,非常实用int MySalary = 123456; String.Format( "{0:C}", MySalary ); // $123,456.00String.Format( "{0:D}", MySalary ); // 123456String.Format……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2331浏览 509个赞
这段代码演示了C#中如何使用Gmail账号发送邮件using System.Web.Mail;using System;public class MailSender{ public static bool SendEmail( string pGmailEmail, string pGmailPassw……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3036浏览 2784个赞
有时候我们知道类的名字,希望根据类名来实例化一个类,下面的代码可以帮你完成/// <summary> /// 根据任务返回处理该任务的对象 /// </summary> /// <param name="task">具体任务</param>……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2681浏览 1712个赞
C#共享文件夹的代码片段System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = " /c ne……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1481浏览 2179个赞
C#读写xml文件的简单范例 //读配置文件 XmlDocument doc = new XmlDocument(); doc.Load("blog.xml"); XmlNode url = doc.SelectSingleNode(&qu……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3059浏览 782个赞
给定两个时间,计算时间差,输出类似于“相差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) 1338浏览 1135个赞
//网站配置文件如下 //要获得数据库文件的物理路径可以通过下面的代码获得:string connStr = ConfigurationManager.AppSettings["connStr"].ToString() + HttpContext.Current.Request.PhysicalApplicat……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2239浏览 1651个赞
1、可以指定文字字体、大小和颜色(注:指定的文字在WEB服务器上需要有该字库); 2、可以加文字阴影; 3、可以指定文字的透明度; 4、可以指定背景图片或背景颜色; 5、可以指定生成的图片大小(宽度与高度); 6、可以指定文字的位置(左边距和上边距); 7、当用户设定的文字字号太大,能自动调整文字大小使之能适应生成图片的大小。 using Sy……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1956浏览 2244个赞
C#可以通过File对象的ReadAllText方法快速读取文本文件File.ReadAllText("c://abc.txt", Encoding.Default);……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3239浏览 744个赞
C#可以通过调用webBrowser控件实现表单的自动填充,包括下拉列表的自动选择HtmlDocument doc = webBrowser1.Document;HtmlElement el = doc.GetElementById("下拉列表框的ID");el.SetAttribute("selectedIndex&……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2525浏览 312个赞
在Windows Form的开发中,我们经常要把应用程序最小化到系统托盘,.net可以很方便的实现,只需要在主窗体上添加一个notifyIcon控件,然后调用下面的代码片段即可: private void Form1_SizeChanged(object sender, EventArgs e) { ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2059浏览 2826个赞