求最大连续子序列一开始想到的一种O(n^2)的算法,应该会超时运用动态规划的思想,想出了下面的方法#include using namespace std;struct DP{ int sum,sta,end; void init(int su,int st,int en){ sum=su; sta...
分类:
其他好文 时间:
2014-07-19 18:04:36
阅读次数:
230
利用二级指针删除链表内一个元素,传统的做法是:找到将要删除元素的前一个指针,然后再删除当前元素。代码示例:void delete_node( elem_type x, struct node* l ){struct node* p = find_prev ( x, l );if ( !p->...
分类:
其他好文 时间:
2014-07-19 09:38:58
阅读次数:
240
判断两直线p1p2与q1q2是否相交,用向量叉积来判断如果P x Q >0,则P在Q的顺时针方向;如果P x Q #include #include #include #include typedef struct node{ double x,y;}point;point p1,p2,q1,...
分类:
其他好文 时间:
2014-07-19 09:38:36
阅读次数:
279
一、套接字的地址结构. IPV4套接字地址结构通常也称为"网际套接字地址结构",它以sockaddr_in 命名;POSIX定义如下:#include struct in_addr{ unsigned long s_addr; /*32-bit IPv4 address ...
分类:
系统相关 时间:
2014-07-19 09:34:33
阅读次数:
408
结点定义:1 /*2 * Huffman树结点定义3 */4 struct Node5 {6 ElementType weight; // 结点的权值7 struct Node *leftChild; // 结点的左指针8 struct Node ...
分类:
其他好文 时间:
2014-07-19 09:19:34
阅读次数:
225
结点类型定义: 1 /* 2 * 结点类型 3 */ 4 enum NodeType { head, atom, sublist }; 5 6 /* 7 * 定义广义表的结点结构(注意union的使用) 8 */ 9 struct Node10 {11 Boolean flag;...
分类:
其他好文 时间:
2014-07-19 09:16:35
阅读次数:
257
HDU1754 1 #include 2 3 using namespace std; 4 5 const int MaxSIZE = 2e6 + 10; 6 7 typedef struct { 8 int Max ; 9 int left, right ...
分类:
其他好文 时间:
2014-07-19 09:14:48
阅读次数:
250
引言 考虑下面的结构体定义:1 typedef struct{2 char c1;3 short s; 4 char c2; 5 int i;6 }T_FOO; 假设这个结构体的成员在内存中是紧凑排列的,且c1的起始地址是0,则s的地址就是1,c2的地址...
分类:
编程语言 时间:
2014-07-19 00:37:47
阅读次数:
409
下面得到这段代码可以用在很多地方:只需要自己修改下接Ok. 1 struct Matrix 2 { 3 long long mat[N][N]; 4 Matrix operator*(const Matrix m)const//定义矩阵乘法的运算符* 5 { 6 ...
分类:
其他好文 时间:
2014-07-19 00:22:01
阅读次数:
187
很多初学者或者是想当然,或者是被网上的一些错误信息给误导,面试中问到class和struct区别时经常会说class可以继承而struct不可以继承,这是完全错误的。但在C#中,class与struct确实有这点区别(当然不止这一点)。其实,在C++中,这两个关键词并没有大的区别,仅在细节上有些不同...
分类:
编程语言 时间:
2014-07-19 00:21:18
阅读次数:
211