c++
文章平均质量分 50
markapril
这个作者很懒,什么都没留下…
展开
-
排列与组合
#include using namespace std;void perm(int a[], int n, int m, int out[], int k, int used[]){ if(k == m) { for(int i =原创 2011-10-12 22:24:21 · 815 阅读 · 0 评论 -
树的某节点的所有父节点
http://blog.csdn.net/yhmhappy2006/article/details/1566865定位一个节点递归实现为:node FindNode(const node root,int val){ node n = root;转载 2011-09-26 23:59:34 · 2399 阅读 · 0 评论 -
树的非递归遍历
http://blog.csdn.net/kofsky/article/details/2886453// 先序遍历伪代码:非递归版本,用栈实现,版本2void preOrder2(TNode* root){ if ( root != NULL)转载 2011-09-26 22:43:05 · 295 阅读 · 0 评论 -
不用临时变量交换两个数的值
当要交换两个数的值时,通常的做法是定义一个临时变量,然后再进行交换。那么能不能不用临时变量而交换两个数的值呢?可以的!C语言提供的异或运算就可以实现这样的操作。 异或运算符^也称XOR运算符,它的规则是若参加运算的两个二进位同号,则结果为0(假);异号为1(真)。即0 ^转载 2011-09-25 23:52:17 · 252 阅读 · 0 评论 -
求素数
#include #include using namespace std;int prim(int a[], int n){ a[0] = 2; int p = 1; for(int i = 3; i < n; i+=2) {原创 2011-09-25 14:46:02 · 225 阅读 · 0 评论 -
八皇后
#includeusing namespace std;const int N = 8;int path[N];void find(int k) //find position in line k{ if(k==N) { for原创 2011-09-22 13:19:17 · 179 阅读 · 0 评论 -
快速排序
//============================================================================// Name : qsort.cpp// Author : a// Version原创 2011-09-24 18:45:47 · 192 阅读 · 0 评论 -
How to Generate C++ Class Template Definitions
c++ class template header and implementation (skeleton) definitions areoften hard to read, let alone to write. Especially when definingtemplate classes that are derived from base temp转载 2010-05-12 02:24:00 · 326 阅读 · 0 评论 -
java c++之不同
java中数组初始化:int[] ai= new int[100];自动使用默认值初始化。C++中数组初始化:int *pai=new int[10] //未初始化或者int *pai = new int[100](); //默认值初始化后面的空括号()表示将数组内容用默认值初始化,即只能使用空括号表示用默认值初始化。原创 2011-11-25 10:03:20 · 255 阅读 · 0 评论