- 博客(5)
- 收藏
- 关注
原创 剑指offer 题目总结(上)
1.反转链表 通过三个指针实现链表反转,还可以通过栈实现 ListNode* ReverseList(ListNode* pHead) { if(pHead==NULL) return NULL; if(pHead->next==NULL) return pHead; ListNode*
2017-01-13 13:04:28 255
原创 二叉树的建立 前序中序后序递归遍历及非递归遍历
#include #include #include #include #include #include #include using namespace std; struct TreeNode { char val; TreeNode *left; TreeNode *right; }; int i = 1; TreeNode* create(){ Tree
2016-11-24 10:20:44 424
原创 七种排序算法*
冒泡排序 void MaoPao(int *a, int len){ for (int i = 0; i for (int j = 0; j { if (a[j]>a[j + 1]) swap(a[j], a[j + 1]); } } 选择排序 void SelectSort(int *a, int len){ for (int i = 0; i { int k
2016-11-18 13:54:33 239
原创 继承多态与虚函数及对类的理解
B是A的子类,子类会继承父类的public方法,子类对象可以调用父类的public接口,但是子类和父类函数重名时,父类的方法会被子类覆盖(隐藏),子类调用和父类同名同参函数或者重载父类的函数后不可以直接调用父类函数,需要加A::fun()调用,父类的protect方法只在继承中有效,子类可以调用父类的protect方法,但是外部无法访问,所以在非继承关系中pretect与private等同,pri
2016-11-17 13:41:30 1197 1
原创 背包问题和八皇后问题
#include #include #include #include #include using namespace std; #define N 5 #define M 5 unsigned int f[100] ; int main() { int weight[6] = { 0, 2, 2, 3, 4, 5 }; int value[6] =
2016-11-17 12:41:38 290
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人