
C
jingsuxuyilq
这个作者很懒,什么都没留下…
展开
-
choose sort
/******************************************************************************* * @version $v1.0$* @date $6.9.2012$* @author $Alfred原创 2012-09-06 15:11:20 · 447 阅读 · 0 评论 -
phony target
$(Program): build_msg $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)$(RM) $@$(CC) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)ls -l $(Program)size $(Program).PHONY: build_msgbuild_msg:@printf "#\n#转载 2012-11-15 22:46:28 · 781 阅读 · 0 评论 -
makefile rule
Makefile Rule在 makefile 中,规则描述了在何种情况下使用什么命令来重建一个特定的文件。特定的文件称为规则的目标;规则的依赖决定了在何种情况下使用命令重建目标;规则的命令用来更新或者创建规则的目标。语法格式如下:targets : prerequisitescommands或者targets : prerequisites ; com转载 2012-11-17 19:46:30 · 3417 阅读 · 0 评论 -
makfile中的自动依赖
现在我们的Makefile写成这样:all: mainmain: main.o stack.o maze.o gcc $^ -o $@main.o: main.h stack.h maze.hstack.o: stack.h main.hmaze.o: maze.h main.hclean: -rm main *.o.PHONY: clean按照惯例,用all做转载 2012-11-18 12:26:58 · 667 阅读 · 0 评论 -
sed
sed 编辑器工具sed(stream editor, 流编辑器) 是一个批处理编辑器。常被作为管道中的过滤器。语法:sed 的命令行语法如下:sed [-n] program [file-list]sed [-n] -f program-file [file-list]sed 工具从命令行所指定的文件或者标准输入中获取输入流,除非明确指定输出目转载 2012-11-18 12:29:33 · 641 阅读 · 0 评论 -
callback函数
一,回调函数我们经常在C++设计时通过使用回调函数可以使有些应用(如定时器事件回调处理、用回调函数记录某操作进度等)变得非常方便和符合逻辑,那么它的内在机制如何呢,怎么定义呢?它和其它函数(比如钩子函数)有何不同呢?使用回调函数实际上就是在调用某个函数(通常是API函数)时,将自己的一个函数(这个函数为回调函数)的地址作为参数传递给那个函数。而那个函数在需要的时候,利用传递转载 2012-12-31 10:13:23 · 818 阅读 · 1 评论 -
Function Pointers and Callbacks in C
Function pointers are among the most powerful tools in C, but are a bit of a pain during the initial stages of learning. This article demonstrates the basics of function pointers, and how to use them转载 2013-01-05 18:10:57 · 986 阅读 · 0 评论 -
transaction
在计算机程序里,事务通常是指一系列信息交换操作以及与其相关的工作(例如数据库更新),为了满足要求以及确保数据库的完整性,这一系列的动作被视为一个整体来执行。一旦一个事务执行结束,数据库就会被永久地修改,所以必须确保事务的整体执行。举一个典型事务的例子:用户打电话预定货物,用户代理把这个预定信息输入计算机。那么这个预定事务包括核查存货数据库看是否有存货,接受预定,确认预定已经接受并确认送货日期几个步转载 2013-02-17 14:36:34 · 676 阅读 · 0 评论 -
二叉树遍历的实现
下面是二叉树的遍历算法实现,不过对于后序非递归的实现还有点点问题,有空再更新。#include #include #include #include #define OK 1#define FAIL 0#define INPUTPARA "%c"#define STACKSIZE 100/**********define some primary data type******原创 2013-03-10 13:34:47 · 812 阅读 · 0 评论 -
microsoft面试题之10
翻转句子中单词的顺序。但单词内字符的顺序不变。例如输入“I am a student." 输出”student. a am I"。算法:先对整个句子进行翻转,再对每个单词时行一次翻转#include #include #include char* wordLength(char *stringPtr, int *len, int *flag){ assert(str原创 2013-04-03 19:52:44 · 797 阅读 · 1 评论 -
复习数据结构之栈
栈是最重要的数据结构之一,所以的函数调用都要用到它,只不过是系统在管理,并且栈在解决实际问题中也很重要。下面贴出常见的对栈的操作。#include #include #include #include #define STACKSIZE 3#define OK 1#define NOK 0typedef int dataType;typedef int status原创 2013-03-21 19:50:04 · 590 阅读 · 0 评论 -
复习数据结构之循环队列
code如下#include #include #include #include #define QUEUESIZE 5#define OK 1#define PARAMETER "%d\n"typedef int dataType;typedef int status;typedef struct sQeue{ dataType *base;原创 2013-03-21 19:57:30 · 608 阅读 · 0 评论 -
复习数据结构之二叉查找树
#include #include #include #include typedef int dataType;typedef struct node * BSTptr;struct node{ dataType data; BSTptr lchild; BSTptr rchild;};BSTptr parent1;BSTptr parent2;void add原创 2013-03-21 20:06:29 · 584 阅读 · 0 评论 -
复习数据结构之队列
直接上code#include #include #include #include #define OK 1#define PARAMETER "%d\n"typedef int dataType;typedef int status;typedef struct QNode{ dataType data; struct QNode * nex原创 2013-03-21 19:55:39 · 545 阅读 · 0 评论 -
共享库的概念
摘自:http://blog.youkuaiyun.com/zuokong/article/details/7006222通常库分为:静态库,共享库,动态加载库,。下面分别介绍。一、 静态库:1.概念:静态库就是一些目标文件的集合,以.a结尾。静态库在程序链接的时候使用,链接器会将程序中使用到函数的代码从库文件中拷贝到应用程序中。一旦链接完成,在执行程序的时候就不需要静态库了。 由转载 2013-04-08 21:23:20 · 730 阅读 · 0 评论 -
fgets/gets, fputs/puts区别
#include char *fgets(char *restrict buf, int n, FILE *restrict fp);char *gets(char *buf);若成功返回指针buf,若到文件结尾或出错返回指针NULLfgets用于从指定文件流fp指向的文件中,将换行符连同它前面的字符读到buf中,当然字符总数(包括换行符)要小于n - 1。因为此buf是以NU原创 2013-04-24 20:23:28 · 1401 阅读 · 0 评论 -
-just-print(or -n)
One of the most useful is -just-print(or -n) which tells make to display the commands it would execute for a particular target without actually executing them. This is particular valuable while writin翻译 2012-11-15 21:48:25 · 1036 阅读 · 0 评论 -
gcc中的-I, -L -l
-I dir把目录“dir”加到目录列表中,而这一目的是为了搜索头文件。 以-I开头的目录将先于标准的系统include的目录被查找。如果“dir”目录就是标准的系统include目录,那这个选项将被忽略,为的是保证上述规则不被破坏。-I library当链接时,搜索以library为名的库。如果你写这个选项在命令中时,情况将会有所不同。链接器将按照指定的顺序查找和处理库和翻译 2012-11-15 21:26:58 · 908 阅读 · 0 评论 -
divide-and-conquer
break the problem into several subproblems that are similar to the original problem but smaller in size, solve the subproblems recursively, and then combine these solutions to create a solution to the原创 2012-09-06 16:33:53 · 473 阅读 · 0 评论 -
insert sort
/******************************************************************************* * @version $v1.0$* @date $6.9.2012$* @author $Alfred原创 2012-09-06 10:41:17 · 318 阅读 · 0 评论 -
max sub array of the given array
/******************************************************************************* * @version $v1.0$* @date $6.10.2012$* @author $Alfred$原创 2012-09-07 17:10:33 · 528 阅读 · 0 评论 -
【C/C++和指针】深度解析---指针与数组 【精华】
一,引例子二维数组可以使用指向数组的指针代替,而指针数组才可以用指向指针的指针代替。[html] view plaincopy#includeiostream> using namespace std; void main() { char *a[]={"Hello","the","World"}转载 2012-09-08 19:46:57 · 592 阅读 · 0 评论 -
max subarray with O(N)
今天有事,下面的代码是我在公交车上用手机写的,格式可能有些不对,在看完《算法导论》上的divide-and-conquer后,我隐隐记得《编程之美》中好像有,我刚刚查了下书,果真,这个算法被称为“联机算法”,不过书中没用给出对应子数组的下标。思想是:1.从数组的第一个元素依次往后加,如果遇到和为负的就将其丢掉,从第一个非负数开始,因为有负数一定会减小其后面的和。2. 在其和都大于0的情原创 2012-09-08 19:09:52 · 1941 阅读 · 1 评论 -
max sub array——dynamic programming
#include #include #define NUM 10int main(void){ int a[NUM] = { -2,4,-8,-23,37,23,1,-2,-10,54}; int begin, end, maxValue; int maxSubarray (int *a, int num, int *left, int * right); maxValue =原创 2012-09-09 11:40:59 · 417 阅读 · 0 评论 -
很好的帖子
12个有趣的C语言面试题转载 2012-09-08 19:27:46 · 544 阅读 · 0 评论 -
heap sort
#include #include void swap( int *temp1, int *temp2 ) //exchange two numbers{ int temp; temp = *temp1; *temp1 = *temp2; *temp2 = temp;}void MaxHeapify(int *arr, int i, int size)原创 2012-09-10 21:32:24 · 407 阅读 · 0 评论 -
generate the random number between a to b
/**********************************************************@brief: generate the random number between a to b**********************************************************/#include #include #include原创 2012-09-09 19:35:58 · 1050 阅读 · 0 评论 -
A Priority Queue
下面是实现优先队列的C代码,其中一定的很多不足,希望大家多多指教!如果大家有什么好的编程规范也可以告诉我,谢谢!/********************************************************************************** * @frief implement a simple priority queue*原创 2012-09-11 20:40:56 · 734 阅读 · 0 评论 -
Quick Sort
#include #define NUM (int)(10)/********************************************************************************** * @brief exchange two numbers *tempPtr1 and *tempPtr2* @param temp原创 2012-09-11 13:51:11 · 504 阅读 · 0 评论 -
ugly number(丑数)
今天来了一哥们面试,我们老大让他写下面的程序,这哥们挺牛的,5分钟就写好了,NB,老大灰常满意:其实这是考查对动态规划的理解。题目:把只包含因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含因子7。习惯上我们把1当做是第一个丑数。求出第n个丑数。/********************************************原创 2012-09-12 22:53:01 · 2274 阅读 · 0 评论 -
搜狗的笔试题
以前找工作的时候去笔试搜狗遇到下面的题目,当时就崩溃了,呵呵,后来我在优快云上发帖了。不过还是不懂。今天在网上看到了一个和这个问题差不多的问题。我决定一定要搞定它。苦思冥想了2小时加高人同事的提示,写出下面算法。题目:一个长度为n的数组a[0],a[1],...,a[n-1]。现在更新数组的各个元素,即a[0]变为a[1]到a[n-1]的积,a[1]变为a[0]和a[2]到a[n-1]的积,..原创 2012-09-13 17:30:01 · 1357 阅读 · 0 评论 -
gcc选项参数-M
翻译自GCC的帮助文档:-M 不是输出预编译过程的结果,而是输出一个用于make的规则,该规则描述了这个main源文件的依赖关系。预编译器输出的这个make规则包含名字与原文件相同的目标文件,冒号和所有include文件的名字。这些include文件主要来自于-include或-imacros命令行选项。除非明确的指定-MT或-MQ,否则目标文件名由两部分组成:源文件名加目标文件后缀和可以翻译 2012-11-11 20:08:54 · 5234 阅读 · 0 评论 -
reference counting C complentation
#include #include //the struct of memory objecttypedef struct { unsigned int referCount; void * data;} memoryObject;void * myAlloc(unsigned int size){ memoryObject * src; char *原创 2014-02-27 15:58:03 · 1203 阅读 · 0 评论