- 博客(25)
- 收藏
- 关注
原创 系统问题查询
1. 如何查询问题:当我们的程序被系统kill掉的时候,一般是可能是内存使用量过大导致的,系统的log一般存放在:/var/log/messages-20160313 底下, 如果搜到了Mar 8 16:42:26 AFCollect01 kernel: ads invoked oom-killer: gfp_mask=0x280da, order=0, oom_score_a
2016-03-14 17:42:33
469
原创 data structure -- tree
1. 层序遍历:递归方法:先遍历特定层。 level 指的是第几层,从1开始。只打印当level == 1的节点,其余全部忽略void print_single_level(TNode* root, int level){ if (!root) return; if (level == 1) { cout v
2016-02-28 08:41:41
459
原创 list 基本操作 1 -- 创建,插入,删除,计算长度
list 的基本操作,包括list 创建,插入,删除,长度计算 ( 迭代和递归算法)//linked list study#include #include #include using namespace std;struct Node{ int val; struct Node* next; Node() { next = N
2016-02-20 16:17:12
527
原创 什么时候需要些析构函数
当我们声明的class的构造函数中使用了new, 那我们需要在这个class析构的时候delete, 否则会造成内存泄露,此时,我们需要写class 的析构函数,显示delete掉指针。#include #include #include using namespace std;struct CP{ int a; int b;};class TEST{publ
2016-02-20 11:08:14
1319
原创 bit 操作
1. 将一个数转为二进制 ( 一共8位),交换前后4位,得到新生成的数:#include #include #include using namespace std;int revert_binary(int a){ int b = ((a & 0x0F) > 4); return b;}int main() { //code int a,
2016-02-20 10:37:23
379
原创 remove the duplicate node from unsorted list
ListNode* removeDuplicate(ListNode* L){ ListNode* dummy = new ListNode(-1); dummy->next = L; ListNode* pre = dummy; unordered_map M; while(L) { if(M.find(L->val) != M.
2014-08-10 19:40:19
415
原创 树相关操作
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti
2014-06-08 21:05:02
431
原创 广度优先
1) word ladder// OOD.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include#include#include#include#includeusing namespace std;int ladderlength(string start, string
2014-06-06 10:28:01
451
原创 深度优先搜索
1) 回文数分割:bool ispalindrome(string s){ if(s.size() < 2) return true; bool result = true; for(int i = 0 ; i < s.size()/2; i++) { if(s[i] != s[s.size()-i-1]) { result = false; break;
2014-06-05 19:54:46
510
原创 面向对象设计1
Design the data structures for a generic deck of cards/}int main(){Card c;cout c.print();c.shuffle();cout c.print();cout Suit s = c.pickone(0);cout system
2014-06-03 22:44:51
762
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人