自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(65)
  • 收藏
  • 关注

转载 伙伴系统算法详解

参考 http://www.voidcn.com/blog/EmbedStudio/article/p-3848869.html 看一下这篇blog下面的碎片解决问题的链接

2016-10-06 11:18:22 2183

转载 外部碎片和内部碎片的区别

外部碎片和内部碎片的区别 这几天一直看操作系统,看到内存的连续分配时,对于外部碎片和内部碎片时甚是不解,刚好在某论坛上发现了这样一个生动的讲解,便迫不及待的相遇大家分享一下。 外部碎片,是由于大量信息由于先后写入、置换、删除而形成的空间碎片。为了便于理解,我们将信息比作货物,将存储空间比作仓库来举例子。假设,我们有编号为1、2、3、4、5、6的6间仓库库房,前天送来了一大宗货,依次装入了1、2

2016-10-06 10:45:52 5701 1

原创 centos 开启DHCP服务

ONBOOT = YES然后重启网络

2016-09-28 22:05:09 3619

转载 container_of函数原理分析

/** * container_of - cast a member of a structureout to the containing structure * @ptr: the pointer to the member. //指向成员变量的指针 * @type: the type of the Container struct this is embed

2016-09-23 23:07:48 379

原创 《APUE:chapter 13 》守护进程测试

P375 想要初始化为守护进程的程序调用daemonize函数 #include <apue.h> 2 #include <syslog.h> 3 #include <fcntl.h> 4 #include <sys/resource.h> 5 6 void daemonize(const char *cmd) 7 { 8

2016-09-16 18:35:28 449

原创 异或运算

具体应用 1.世界上有10种人,一种懂二进制,一种不懂。那么你知道两个int32整数m和n的二进制表达,有多少个位(bit)不同么? 输入例子: 1999 2299输出例子: 7思路: 注意负数(先转换为正数),int 有32位,故:先将两个数异或,结果&上掩码x=1;如果真,则count++;然后m,n 分别左移1位(循环32次)#include <iostream>using nam

2016-09-12 22:08:24 929

转载 C语言指针总结

http://www.cnblogs.com/jyaray/archive/2010/06/03/1751056.htmlC语言中的精华是什么,答曰指针,这也是C语言中唯一的难点。C是对底层操作非常方便的语言,而底层操作中用到最多的就是指针,以后从事嵌入式开发的朋友们,指针将陪伴我们终身。本文将从八个常见的方面来透视C语言中的指针,当然,还有其他没有具体提到的方面,像指针表达式、指针安全等问题,以后

2016-09-12 21:57:23 232

原创 数据结构与算法(c)--第4章

4.2.2 构造一棵表达式树 代码如下:#include <iostream>#include <string>#include <sstream>#include <stack>using namespace std;typedef char ELEMENT;typedef struct TreeNode{ ELEMENT vlaue; struct TreeNode

2016-09-08 09:41:19 1040

原创 Linux设备驱动程序(0)

环境: (没有使用网上教程编译2.6.xx的标准内核来建立内核目录树,而是直接在自己的虚拟机上面进行测试,其实3.19.0-25-generic 应该属于内核目录树)编写书上的测试驱动程序: #include <linux/init.h> 2 #include <linux/module.h> 3 4 MODULE_LICENSE("Dual BSD/GPL"); 5

2016-09-06 19:43:14 1443

原创 Linux中编译C/C++多线程程序

编译执行多线程程序编译上述多线程程序,必须使用 -lpthread编译选项,因为pthread库不是Linux默认链接库,链接时必须指定使用libpthread.a库(ubuntu11.10这些库在/usr/lib/i386-linux-gnu路径下),在编译选项中需添加-lpthread参数,示例如: C编译选项: gcc test.c -o test -lpthread C++编译选

2016-09-04 14:52:40 2878 1

转载 C/C++中extern关键字详解

参考: http://www.cnblogs.com/yc_sunniwell/archive/2010/07/14/1777431.html

2016-09-02 12:30:27 219

原创 二叉排序树

二叉排序树:又称“二叉查找树”、“二叉搜索树” 二叉排序树:或者是一棵空树,或者是具有下列性质的二叉树:若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值;若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值;它的左、右子树也分别为二叉排序树 二叉排序树通常采用二叉链表作为存储结构,中序遍历二叉排序树可得到一个依据关键字的有序序列;搜索、插入、删除的时间复杂度等于树高,期望

2016-09-02 12:29:16 324

原创 详解文件的写入和文件同步

为了提高文件的写入效率,在现代操作系统中,当用户调用write函数,将一些数据写入到文件的时候,os通常会将写入数据暂时保存在一个内存缓冲区里面(例如,unix系统实现在内核中设有缓冲区高速缓存或页高速缓存,当我们向文件写入数据时,内核通常先将数据复制到缓冲区中,然后排入队列,晚些时候再写入磁盘),这种方式称为延迟写,等到缓冲区的空间被填满,或者超过了指定的时限,或者内核需要重用缓冲区存放其它磁盘块

2016-08-26 15:06:18 4483

原创 多叉树的设计、建立、层次优先遍历和深度优先遍历

参考: http://www.cnblogs.com/unixfy/p/3486179.html用户的多叉树数据存储在一个文件中,格式如下: aA 4 g cC z bBbB z 2 f i g 1 d d 3 x e j 每行的第一个元素指定一个节点,第二个元素表示该节点有几个子节点,紧接着后面跟了几个子节点;/* 算法1:层次优先遍历多叉树(队列)

2016-08-25 08:59:59 16448

原创 linux下遇到觉得有用的命令

who : 读取数据文件utmp文件,此文件记录当前登入到系统的各个用户 last : 读取数据文件wtmp文件,此文件跟踪各个登入和注销事件 (高编P149) uname :读取系统,机器相关的信息(用法:uname –help 然后 uname -a) time :命令,指示程序运行的时间(用法:time +执行程序,如:time ./a.out)

2016-08-23 22:15:57 332

原创 《UNIX环境高级编程》第5章标准IO中的内存流

详细参考: http://blog.csdn.net/drdairen/article/details/51912828

2016-08-23 21:10:59 547

原创 Simpelscalar

1.what’s Simplescalar ? http://www.ecs.umass.edu/ece/koren/architecture/Simplescalar/SimpleScalar_introduction.htm http://www.simplescalar.com/docs/simple_tutorial_v4.pdf2.安装: http://www.cnblogs.com

2016-08-22 16:07:46 501

原创 IO:输入输出

不带缓冲I/O 例如:函数open,read,write,lseek以及close 提供不带缓冲的I/O; (高编P7) 标准I/O 标准I/O函数为那些不带缓冲的I/O函数提供了一个带缓冲的接口,使标准I/O函数无需担心如何选取最佳缓冲区的大小(因为缓冲区的大小会影响程序的效率),所以的标准I/O函数定义在#include< sdtio.h>中。(高编P8)

2016-08-19 23:07:53 294

原创 虚拟机问题

主机中的文字复制后无法粘贴到虚拟机中:解决 虚拟机的工具栏-》虚拟机》设置》选项》共享文件夹

2016-08-19 14:59:32 292

原创 编译器:GCC / Clang

编译器架构: 理解Blog中:三、STL、ABI、UNWIND层次关系 http://blog.csdn.net/vloong/article/details/19070443 上图分析: g++complier是g++编译的,先调用其标准库libstdc++(包含了libsupc++),然后标准库又依赖libgcc_s,往下又依赖libc.so; clangcompiler是cl

2016-08-19 14:52:42 3156

原创 linux :常用命令

软件安装管理命令: 3种安装方法:http://www.cnblogs.com/xwdreamer/p/3623454.html apt-get / PPA介绍 https://linux.cn/article-5982-1.html http://os.51cto.com/art/200802/65583.htm 注意: 添加环境变量: 下载的第三方软件运行,如果没有将软件目录下的b

2016-08-19 14:23:29 353

原创 Vim:常用命令

gg : 跳转到文件头 Shift+g : 跳转到文件末尾 行数+gg : 跳转到指定行,例跳转到123行:123gg h 光标向左移动一个字符 j 光标向下移动一行 k 光标向上移动一行 l 光标向右移动一个字符Ctrl + f 屏幕『向下』移动一页 Ctrl + d 屏幕『向下』移动半页 Ctrl + b 屏幕『向上』移动一页 Ctrl + u

2016-08-19 14:13:36 317

原创 vim :创造IDE环境

参考Blog https://github.com/yangyangwithgnu/use_vim_as_ide/tree/master#5.4 http://harttle.com/tags.html#Vundle其中YCM安装: https://github.com/Valloric/YouCompleteMe#full-installation-guide 配置要求: 安装cmak

2016-08-19 13:59:45 405

原创 C语言定义可变参数列表的函数

定义一个可接受可变参数列表的函数,在访问一个可变参数列表中额外的参数,需要使用< stdarg.h > 中定义的宏 例如: void func(参数1,参数2,参数parmN…) … 为可变参数列表 头文件 < stdarg >声明了一种类型且定义了3个宏,函数func在被编译时并不知道这个参数表中参数的数目和类型,在这种访问机制中,最右边的参数parmN起特殊的作用va_list 类型 :保

2016-08-16 23:48:29 543

原创 Ubuntu中文输入法配置,以及yahei consolas hybrid 字体

中文输入法配置: sudo apt-get install fcitx sudo apt-get install fcitx-Sunpinyin 然后进入系统设置->keyboard-> 在IDE环境下安装yahei consolas hybrid 字体window下: 前端最爱的字体YaHei Consolas Hybrid内容linux下: ubuntu下安装教程

2016-08-16 13:15:20 1551

原创 9. Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.判断一个int数是否是回文? 解法:转换为字符串, 字符串判断回文很简单for (int i = 0, j = s.size() - 1; i != s.size() / 2; i++, j--){ if (s[i] != s[j]) re

2016-08-15 14:40:40 272

原创 8. String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.N

2016-08-14 23:04:19 270

原创 7. Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321click to show spoilers.Have you thought about this? Here are some good questions to ask before coding. Bonus

2016-08-14 12:11:51 276

原创 6. ZigZag Conversion

The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N A P L S I I G

2016-08-13 23:43:11 202

原创 5. Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.分析:求最长的回文子串,时间赋值度n平方;aaa

2016-08-13 21:50:49 229

原创 4. Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1: nums1 = [1, 3] num

2016-08-12 20:04:10 223

原创 3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length is 3.Given “bbbbb”, the answer is “b”, with the le

2016-08-12 16:58:48 327

原创 总结:深搜+回溯的一般思路

1.定义全局数据结构 2.递归函数中注意: (1).递归函数的出口 (2).此阶段包括多少候选项 (3).编写条件函数,剪枝 (4).满足条件时的标记,递归,以及递归返回时是否恢复标记 3.输入map中数据是否考虑去重(比如《blog深搜索2》,全排列)

2016-08-11 23:31:29 2525

原创 oj:深搜+回溯(4)

题目《算法分析与设计》P280#include <iostream>#include <string>#include <map>using namespace std;char imap[21][21]; //图大小int flag[21][21]; // 标记是否访问过int ilen; // 周长int ix, iy; // 图的行列int iposx, iposy;

2016-08-11 23:19:02 346

原创 2. Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linke

2016-08-11 16:33:18 254

原创 1. Two Sum

QuestionGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example: Given nums = [2

2016-08-11 10:49:06 223

原创 oj:深搜+回溯(3)

求几个数的全排列:#include <iostream>#include <string>using namespace std;int map[100]; //假设排列数的个数最多为100int n;//实际个数int q;//多少种不同的数int icount[100];//存放每种不同的数的个数。数组大小由q决定int itable[100];//存放一种排序int num;

2016-08-10 23:08:24 317

原创 oj:深搜+回溯(2)

参考《算法设计与分析》P276#include <iostream>#include <string>using namespace std;int map[25][4];int n;int q;int icount[25];int itable[25];int place(int pos){ if (pos == n*n)return 1; //递归出口 for (i

2016-08-10 22:28:16 424

原创 OJ:深搜+回溯(1)

参考解析 《算法分析与设计》P273#include <iostream>#include <string>using namespace std;/* 全局变量: 1.定义map空间的大小 2.具体大小n 3.最优best*/char map[5][5];int n;int best; /* 判断满足条件*/bool conditi

2016-08-10 15:23:45 298

原创 经典面试题集合

一个fork的面试题 http://coolshell.cn/articles/7965.html

2016-08-09 18:34:20 235

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除