之前使用过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
题目链接:点击打开链接
题意:有两种操作,合并集合,查询第K大集合的元素个数。(总操作次数为2*10^5)
Treap模板(静态数组)
#include
#include
#include
#include
#include
const int maxNode = 500000 + 100;
const int inf = 0x3f3f3f3f;
struct Tr...
分类:
其他好文 时间:
2014-05-24 23:18:09
阅读次数:
522
/*---分别对单链表和双链表,只使用指针来交换两个相邻的元素。---*/
/*-单链表版本-*/
#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
#include
#include
#include //system(); 这个指令需要用到此头文件
#include //toupper要用到
#include //在内存管理时用到的头文件
void main()
{
int i;
struct ListEntry{
int number; //数据域
struct ListEntry *next; //指向 下...
分类:
其他好文 时间:
2014-05-24 18:15:27
阅读次数:
258
/*---给你一个链表L和另一个链表P,它们包含以升序排列的整数。操作PrintLots(L,P)
将打印L中那些由P所指定位置上的元素。---*/
#include
#include
struct Node{
int val;
struct Node *next;
};
Node *findEnd(Node *list){
while(list->next) list = l...
分类:
其他好文 时间:
2014-05-24 14:27:42
阅读次数:
224