摘要: 真正的勇士,敢于直面惨淡的人生,敢于正视淋漓的鲜血 ——鲁迅 阅读全文
posted @ 2012-05-22 09:09 王耀it 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 真正的勇士,敢于直面惨淡的人生,敢于正视淋漓的鲜血 ——鲁迅 这篇博文总结一下图的有关算法。转载请注明出处http://www.cnblogs.com/tianji,谢谢! 图的表示 要表示一个图G=(V,E),有两种标准的表示方法,邻接矩阵和邻接表。这两种方法都可用于有向图和无向图。对于稀疏图,常用邻接表表示,因为这样表示图更为紧凑(图中|E|要远小于|V|*|V|);当遇到稠密图或者必须很快判别两个给定顶点是否存在连接边时,一般采用邻接矩阵表示。 图G=(V,E)的邻接表表示由一个包含|V|个列表的数组Adj所组成,其中每... 阅读全文
posted @ 2012-05-20 16:58 王耀it 阅读(600) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2012-05-20 13:08 王耀it 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 求子数组的最大和题目描述:输入一个整形数组,数组里有正数也有负数。数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和。求所有子数组的和的最大值。要求时间复杂度为O(n)。例如输入的数组为1, -2, 3, 10, -4, 7, 2, -5,和最大的子数组为3, 10, -4, 7, 2,因此输出为该子数组的和18。代码:int maxsum(int *a,int n){ int tmp=0; int max=0; for(int i=0; i<n; i++) { if(tmp<0) tmp=a[... 阅读全文
posted @ 2012-05-19 14:41 王耀it 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 原题:To the MaxTime Limit:1000MSMemory Limit:10000KTotal Submissions:31305Accepted:16272DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of al 阅读全文
posted @ 2012-05-19 13:41 王耀it 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 12章 类1、类的成员函数有一个附加隐含实参,将函数绑定到调用函数的对象。13章 复制控制1、复制构造函数是一种特殊构造函数,具有单个形参,该形参(常用 const 修饰)是对该类类型的引用。当定义一个新对象并用一个同类型的对象对它进行初始化时,将显式使用复制构造函数。当将该类型的对象传递给函数或函数返回该类型的对象时,将隐式使用复制构造函数。2、析构函数是构造函数的互补:当对象超出作用域或动态分配的对象被删除时,将自动应用析构函数。析构函数可用于释放对象时构造或在对象的生命期中所获取的资源。不管类是否定义了自己的析构函数,编译器都自动执行类中非 static 数据成员的析构函数。3、与构造函 阅读全文
posted @ 2012-05-18 21:22 王耀it 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 原题:The TriangleTime Limit:1000MSMemory Limit:10000KTotal Submissions:28546Accepted:16809Description73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends som... 阅读全文
posted @ 2012-05-18 17:35 王耀it 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 1、面向对象编程基于三个基本概念:数据抽象、继承和动态绑定。在C++中,用类进行数据抽象,用类派生从一个类继承另一个:派生类继承基类的成员。动态绑定使编译器能够在运行时决定是使用基类中定义的函数还是派生类中定义的函数。 阅读全文
posted @ 2012-05-18 17:21 王耀it 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 1、硬链接vs符号链接 ln命令: ln -s vs ln2、ls -l命令 第一行的total字段表示目录下的文件占磁盘占有量 单位为kB3、chmod [who] operator [permission] filename vs chmod [-R] [mode] filenamewho可选项:u g o a permission可选项:r w x s t lmode为八进制 -R选项表示连同子目录一起设置权限目录的r w x权限意义稍有不同 且目录的权限会覆盖包含文件的权限4、设置suid/guid位 :在chmod [4+2][mode] filename 4表示suid 2表示g. 阅读全文
posted @ 2012-05-16 21:21 王耀it 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 1、多线程优点:(1)We can simplify code that deals with asynchronous(异步事件) events by assigning a separate thread to handle each event type. Each thread can then handle its event using a synchronous programming model. A synchronous programming model is much simpler than an asynchronous one.(2)Multiple proces 阅读全文
posted @ 2012-05-15 21:04 王耀it 阅读(240) 评论(0) 推荐(0) 编辑