之前使用过cocos2d-x获取系统时间,毫秒级的
[cpp] view
plaincopy
long getCurrentTime()
{
struct timeval tv;
gettimeofday(&tv,NULL);
return tv.tv_sec * 10...
分类:
其他好文 时间:
2014-05-26 05:37:49
阅读次数:
358
题目:输入一颗二叉树的根结点,判断该二叉树是不是平衡二叉树。平衡二叉树是满足所有结点的左右子树的高度差不超过1的二叉树
方案一:遍历数组的每一个结点,对每一个结点求它的左右子树的高度并进行判断。时间复杂度大于O(n),小于O(n^2)效率较低,因为有很多点需要重复访问。
//二叉树的结点
struct BinaryTreeNode{
int m_value;
Bin...
分类:
其他好文 时间:
2014-05-26 04:34:53
阅读次数:
192
sleep_on用于进程休眠,原型如下:
void sleep_on(struct task_struct **p)
当进程访问某个互斥资源时,如果资源被另外进程占用,当前进程就需要休眠。
假设资源的结构如下:
struct res
{
....
struct task_struct *wait;
}
其实我们参考下文件系统的i节点就会发现,i节点也是一种资源,它的结构体中就有一...
分类:
系统相关 时间:
2014-05-26 04:28:02
阅读次数:
439
结构体(struct)的位字段(:) 详解
本文地址: http://blog.csdn.net/caroline_wendy/article/details/26722511
结构体(struct)可以使用位字段(:), 节省空间, 如以下代码,
结构体a中的, 第一个变量x占用1个字符, y占用2个字符, z占用33个字符(越界);
但是sizeof()会自动补齐, 如x+y一共占用4个字节, z占用8个字节, 所以...
分类:
编程语言 时间:
2014-05-26 04:12:18
阅读次数:
514
1. 两栈共享空间结构
typedef struct
{
SElemType data[MAXSIZE];
int top1; /* 栈1栈顶指针 */
int top2; /* 栈2栈顶指针 */
}SqDoubleStack;...
分类:
编程语言 时间:
2014-05-26 03:52:28
阅读次数:
391
1.链栈结构
typedef struct StackNode
{
SElemType data;
struct StackNode *next;
}StackNode,*LinkStackPtr;
typedef struct
{
LinkStackPtr top;
int count;
}LinkSta...
分类:
编程语言 时间:
2014-05-24 23:35:39
阅读次数:
429
/*---分别对单链表和双链表,只使用指针来交换两个相邻的元素。---*/
/*-单链表版本-*/
#include
#include
struct Node{
int val;
struct Node *next;
};
Node *findEnd(Node *list){
while(list->next) list = list->next;
return ...
分类:
其他好文 时间:
2014-05-24 19:41:49
阅读次数:
253
//
// fs_stream.h
// fsnet
//
// Created by Vincent on 14-5-22.
// Copyright (c) 2014年 Vincent. All rights reserved.
//
#ifndef fsnet_fs_stream_h
#define fsnet_fs_stream_h
#include "fs_define.h"...
分类:
其他好文 时间:
2014-05-24 18:19:34
阅读次数:
372
设两线段为(x1,y1) ,(x2,y2),
若使两线段相交,需使x1y2||x1>x2&&y1 2 #include 3 #include 4 #define MAXH 1005 5
using namespace std; 6 7 int n, m, k; 8 struct mem{ 9 ...
分类:
其他好文 时间:
2014-05-24 12:43:55
阅读次数:
333
#includeusing namespace std;template class
Stack{ private: struct Node{ Object data; Node * next; Node(cons...
分类:
其他好文 时间:
2014-05-24 09:32:25
阅读次数:
215