大家好,本人被下面这个问题困扰了一段时间,最近似乎找到了答案。这里和大家分享一下,可能对有相同困惑的同学有点帮助,同时也请各位帮忙看看错漏的地方。1================问题:在使用pthread库创建两个线程时clone()被调用了两次,可以用strace 看到:intmain(){.....
分类:
编程语言 时间:
2014-07-07 15:08:35
阅读次数:
209
从树的中序遍历+前/后序遍历重建一棵树。必须使用iterator才能过,否则会MLE。1、preorder + inorder第一个版本,使用坐标范围: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int...
分类:
其他好文 时间:
2014-07-07 14:11:10
阅读次数:
147
如果按层次遍历,存下每一层的点,会MLE。1、递归版本:关键还是子问题的划分。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * ...
分类:
其他好文 时间:
2014-07-07 13:58:07
阅读次数:
181
判断一棵树是不是平衡二叉树,之前做过,还有点印象,用一个函数返回树的高度,如果是-1的话,就说明子树不平衡。1A很开心~ 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * T...
分类:
其他好文 时间:
2014-07-07 13:56:05
阅读次数:
180
在LINUX的时钟中断中涉及至二个全局变量一个是xtime,它是timeval数据结构变量,另一个则是jiffies,首先看timeval结构struct timeval{time_t tv_sec; /***second***/susecond_t tv_usec;/***microsecond*...
分类:
系统相关 时间:
2014-07-02 00:54:24
阅读次数:
631
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *...
分类:
其他好文 时间:
2014-06-30 23:36:56
阅读次数:
211
C 结构体小结关于结构体的声明:# include //第一种方式struct Student{ int age; float score; char sex;};//第二种方式struct Student2{ int age; float score; char...
分类:
其他好文 时间:
2014-06-30 23:18:58
阅读次数:
336
#include
#include
#define INITITY 999//最大值
#define VERTEX 20//最多顶点个数
#define FALSE 0
#define TURE 1
#define size 30
#define OVERFLOW -1
typedef struct ArcCell{
int adj;//权值类型
}ArcCell,AdjMatrix[VE...
分类:
其他好文 时间:
2014-06-30 19:44:49
阅读次数:
313
下面这个散列表的实现来自K&R,很经典。在其他场景中遇到的实现更复杂,基本原理不变,只是在hash算法,或者在快速查询上做了优化。
#include
#include
//具有相同hash值构成的链表
struct nlist{
struct nlist
* next;
char * name; //key-定义的名字
char ...
分类:
其他好文 时间:
2014-06-30 19:08:53
阅读次数:
209
属性的存储 属性的主要作用是存储数据,可以常量属性和变量属 性;struct FixedLengthRange {
var firstValue: Int let length: Int
}
var rangeOfThreeItems =FixedLengthRange(firstValue: 0,
length: 3)
// the range represents integer value...
分类:
其他好文 时间:
2014-06-30 18:53:33
阅读次数:
271