题解:用a[i]表#include #include using namespace std;struct data{int len,a[2002];}a[35],c,p,t;int n,d;data mul(data a,data b){ memset(c.a,0,sizeof c.a); ...
分类:
其他好文 时间:
2014-07-22 00:35:36
阅读次数:
235
enum T{ status1, status2,}Linux下:1.做函数返回值时enum T f();不能写成T f();2.if(i == status1)不能写成 if(i == T::status1)编译器版本信息:#g++ -vUsing built-in specs.Target: x...
分类:
系统相关 时间:
2014-07-21 11:27:30
阅读次数:
275
约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。
C代码如下:
#include
#include
#include
typedef struct _node
{
struct _node* next;...
分类:
其他好文 时间:
2014-07-21 09:32:50
阅读次数:
222
矩阵的快速幂sn 1 1 0 0 sn-1fn+1 = 0 3 2 7* fnfn 0 1 0 0 fn-1fn-1 0 0 1 0 fn-2#include #include using namespace std;int n;struct M{ int t[4][4]...
分类:
其他好文 时间:
2014-07-21 08:07:13
阅读次数:
221
一.类与结构的示例比较: 结构示例: 1 public struct Person 2 { 3 string Name; 4 int height; 5 int weight 6 public bool overWeight() 7 { 8 //implement something ...
分类:
其他好文 时间:
2014-07-20 23:39:51
阅读次数:
317
UVA 11149 - Power of Matrix
题目链接
题意:给定一个n*n的矩阵A和k,求∑kiAi
思路:利用倍增去搞,∑kiAi=(1+Ak/2)∑k/2iAi,不断二分即可
代码:
#include
#include
const int N = 45;
int n, k;
struct mat {
int v[N][N];
mat() ...
分类:
其他好文 时间:
2014-07-20 23:07:20
阅读次数:
274
#include
#include
#include
using namespace std;
struct CNode
{
int L,R;
CNode* pLeft,* pRight;
long long Inc;
long long nSum;
};
CNode Tree[200010];
int nCount=0;
int Mid(CNode* pRoot)...
分类:
其他好文 时间:
2014-07-20 22:38:44
阅读次数:
245
采用一维数组建树。(因为一维数组建的是完全二叉树,时间上比用孩子节点指针建树慢,不过基本可以忽略=-=)
#include
#include
#include
using namespace std;
const int INF = 0xffffff0;
int minV=INF;
int maxV=-INF;
struct Node
{
int L,R;
int minV,ma...
分类:
其他好文 时间:
2014-07-20 22:28:44
阅读次数:
216
第十章 结构和联合
这个部分先介绍了.运算符,可以供直接访问,还介绍了->运算符,它代替结构体指针的间接访问操作(*struct).xxx
这一章新手理解起来不算太难,没有学过操作系统的话理解位段、对齐等概念会有一些问题。
越发的说明了指针和内存绝对是C的核心。
总结:
结构声明列出了结构包含的成员列表,不同类型的值可以存储在一起。
不同的结构声明即使他们的成员列表相同也被认为...
分类:
其他好文 时间:
2014-07-20 22:26:03
阅读次数:
300
close:
当套接字的引用计数为0的时候才会引发TCP的四分组连接终止序列;
shutdown:
不用管套接字的引用计数就激发TCP的正常连接终止序列;
这里由一个SO_LINGER套接字选项
struct linger {
int l_onoff; /* 0 = off, nozero = on */
int l_linger; ...
分类:
其他好文 时间:
2014-07-20 22:24:53
阅读次数:
367