- 博客(19)
- 收藏
- 关注
转载 .Net调用非托管代码(P/Invoke与C++InterOP)
1 .Net互操作.Net不能直接操作非托管代码,这时就需要互操作了。1.1 P/Invoke许多常用Windows操作都有托管接口,但是还有许多完整的 Win32 部分没有托管接口。如何操作呢?平台调用 (P/Invoke) 就是完成这一任务的最常用方法。要使用 P/Invoke,您可以编写一个描述如何调用函数的原型,然后运行时将使用此信息进行调用。1.1.1 枚举和常量
2013-10-12 09:40:00
805
转载 FD_WRITE解释
The FD_WRITE network event is handled slightly differently. An FD_WRITE network event is recorded when a socket is first connected with connect/WSAConnect or accepted with accept/WSAAccept, and then a
2013-08-29 16:05:30
775
转载 静态文本设置类:CLabel
CLabel类可以改变 Static 静态文本颜色、背景,或将静态文本设置为超链接,一网友问我如何改变对话框文本颜色(不是全部改变),找到了这个类,自已做了一个示例程序(The original autor's expamle program is not suit for beginner),推荐给大家试试,有好作品别忘了给我寄一份。首先下载类的源程序:下载(含我做的示例程序) (2
2013-08-13 10:15:18
1878
转载 linux源码学习计划
准备条件:必要的内核;必要的文档;必要的机器(虚拟机也可)。 第一周: 1.linux和unix相比有哪些特点? 2.内核编程和用户空间编程相比有哪些不同之处? 3.自己编译一下内核,你编译成功了么?如果不成功,有什么问题?使用你新编译的内核, 能顺利启动么?有什么问题? 4.linux内核源代码树中你能找到sg设备驱动是在那个文件中
2013-03-08 19:45:19
639
原创 单源点最短路径
#include #define INF 10000#define N 8int adj_mtx[N][N];int pre[N];int visited[N];int v;void set(int i, int j, int dist){ adj_mtx[i][j] = dist; adj_mtx[j][i] = dist;}void init(){
2013-01-17 23:36:05
532
原创 八皇后源码
#include#includeusing namespace std;#define MAX 8int queen_array[MAX][MAX];static int NUM=0;void print(){ int i,j; for(i=0;i<MAX;i++) { for(j=0;j<MAX;j++) cout<<queen_array[i
2013-01-15 23:00:18
458
原创 判断一个字符串中是否含有另一个字符串
#includeusing namespace std;bool compare(char *str1,char *str2,int StartIndex,int len){ bool bEqual=true; int i; for(i=0;i<len;i++) { if(str1[StartIndex+i]!=str2[i]) { bEqual=fal
2013-01-03 20:26:43
737
原创 大数除法
大数除法:/*大数相除*/#include#include#includebool CompareTwoNum(char *str1,char *str2,int Str1BeginIndex,int Str1EndIndex,int Str2BeginIndex,int Str2EndIndex){ int i,j,len1,len2; bool GreaterOr
2012-12-12 11:15:09
448
转载 整数二进制中1的个数
题目:输入一个整数,求该整数的二进制表达中有多少个1。例如输入10,由于其二进制表示为1010,有两个1,因此输出2。分析:这是一道很基本的考查位运算的面试题。包括微软在内的很多公司都曾采用过这道题。一个很基本的想法是,我们先判断整数的最右边一位是不是1。接着把整数右移一位,原来处于右边第二位的数字现在被移到第一位了,再判断是不是1。这样每次移动一位,直到这个整数变成0为止。现在的
2012-12-11 13:39:51
379
原创 大数运算
大数相加:/*大数相加*/#include#include#includevoid Move2Right(char str[],int StrEnd,int StrDest){ int i,dist; dist=StrDest-StrEnd; for(i=StrEnd;i>=0;i--) { str[i+dist]=str[i]; } for(i=0;i<d
2012-12-10 12:26:55
436
原创 fprintf fscanf fwrite fread
fprintf和fscanf是一对,他们是以字符形式往内存中写,也就是说无论你往文件里写什么,它通通都把它转成字符再写入;fwrite和fread是一对,他们是以二进制形式往里写,也就是说写的值原本值是什么,就写什么。所以用的时候要注意,不能交叉使用。例如 fprintf写如整数1,内存形式为:0x31,即字符1的 acsii码49;fwrite写入整数1,内存形式为:0x
2012-11-22 09:30:35
669
原创 浮点数精度错误
代码如下:#includeusing namespace std;int main(){ float a=0.05; float b=0.01; float c=1.0; float d=0.42; float e=4.015; float f=100; float g=123.3; cout<<(a+b)<<endl; co
2012-11-22 08:05:06
522
转载 C语言运算符优先级表
优先级运算符名称或含义使用形式结合方向说明1[]数组下标数组名[常量表达式]左到右 ()圆括号(表达式)/函数名(形参表) .
2012-11-20 09:09:47
389
原创 date time server&client
windows date time server:#include #include #include #include #include #include using namespace std;#pragma comment(lib,"Ws2_32.lib")#define IP_ADDRESS "210.47.24.11"#define PORT 13in
2012-11-17 16:12:08
443
转载 InterlockedIncrement
#include#includevolatile long g_nLoginCount;unsigned int _stdcall Fun(void *pPM);const DWORD THREAD_NUM = 50;DWORD WINAPI ThreadFun(void *pPM){ Sleep(10); InterlockedIncrement((PLONG)&g_nLo
2012-11-13 19:03:47
562
原创 基本于STL heap 之 priority_queue
#include#include#includeusing namespace std; class priority_queue{private: vector vec;public: int size(); bool empty(); int top(); void pop(); void push(int n);};int priority_queue::
2012-11-12 18:00:15
408
原创 字典树(trie)
#include#include#includeusing namespace std;#define MAXSIZE 10typedef struct trie{ char *data; struct trie *next[26]; trie():data(NULL) { for(int k=0;k<26;k++) next[k]=NULL; }}TR
2012-11-12 17:02:10
361
原创 归并排序
读了别人的程序,自己重写了一遍,完整代码如下:#includeusing namespace std;#define MAXSIZE 10void print(int a[],int size = MAXSIZE){ int i; for(i=0;i<size;i++) cout<<a[i]<<" "; cout<<endl;}void merge_arr
2012-11-11 20:32:52
354
原创 堆排序实现
今天抽空写了个堆排序的算法,废话不多说,直接上源代码:#include#include#includeusing namespace std;#define MAXSIZE 6void print(int a[],int size = MAXSIZE){ int i; for(i=0;i<size;i++) cout<<a[i]<<" "; cout<<en
2012-11-11 12:32:43
392
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人