暂未发现什么bug,如果发现请指出。#includeusing namespace std;//定义二叉搜索树的结点struct Node{ int data; Node *lc,*rc,*parent;};//中序遍历二叉搜索树void show(Node *now){ if(n...
分类:
编程语言 时间:
2014-08-15 21:08:39
阅读次数:
305
本测试代码包括以下内容:(1)如何使用构造函数;(2)默认构造函数;(3)对象间赋值;(4)const使用语法;(5)定义类常量: 一种方法是用enum,另一种方法是使用static。#include using namespace std;enum sexType{ MAN, WOMA...
分类:
编程语言 时间:
2014-08-15 19:27:29
阅读次数:
301
likely和unlikey函数源码分析
看代码的时候常常遇到likely和unlikely这两个函数,大概知道是用来检测返回值的,但是也不知道是什么。今天实在不爽了,就去看源码了。
在内核代码树的 include/linux/compiler.h里
void ftrace_likely_update(struct ftrace_branch_...
分类:
其他好文 时间:
2014-08-15 17:57:29
阅读次数:
233
a storage class can only be specified for objects and functionsextern修饰一个struct报错,错误原因如上,C++中存储类修饰符有auto、register、extern、static,这几种修饰符只能修饰对象或者函数,这里用ex...
分类:
系统相关 时间:
2014-08-15 17:27:59
阅读次数:
230
StrToInt:字符串转int输出 1 enum Status 2 { 3 kValid = 0, 4 kInvalid = 1, 5 }; 6 7 int StrToInt(const char* str) 8 { 9 g_nStatus = kInvalid;10 long...
分类:
其他好文 时间:
2014-08-15 17:26:29
阅读次数:
168
#include
#include
#include
using namespace std;
struct Data
{
void assign(int x,int y,int z)
{
row=x;
col=y;
val=z;
}
int row,col,val;
} data[730];
struct Node
...
分类:
其他好文 时间:
2014-08-15 16:02:29
阅读次数:
1129
一个简单的三维BFS:
刚开始说内存超出了,就把 标记走过的路语句 和 判断到达终点的语句 放在了push(next)之前
#include
#include
#include
#include
#define N 51
using namespace std;
struct node{
int x,y,z;
int t;
};
int dir[8]...
分类:
其他好文 时间:
2014-08-15 14:45:28
阅读次数:
292
#include#include#include#includeusing namespace std;struct p{int a,b;};bool cmp(p p1, p p2){if(p1.b>p2.b) return true;if(p1.b==p2.b && p1.a>m;while(m-...
分类:
其他好文 时间:
2014-08-15 12:47:48
阅读次数:
281
struct bitmap{ unsigned int len; unsigned char* buf;};struct bitmap* creat_bitmap(unsigned int len){ struct bitmap *bm; if (len buf = ...
分类:
其他好文 时间:
2014-08-15 12:46:48
阅读次数:
213
#include using namespace std;struct node{ int l,w;}dp[1005];int g[1005][1005];int d[1005];int k,max_v;int f(int i){ if (d[i]>0) return d[i]; d[i]=1; f...
分类:
其他好文 时间:
2014-08-15 12:33:58
阅读次数:
197