自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(60)
  • 收藏
  • 关注

原创 mac使用总结(不断更新)

1. 查看系统日志/var/log/system.log

2013-04-27 21:25:07 926

原创 python基础知识总结(不断更新)

1.  访问控制对于__开头的类变量或成员变量,python会认为其是私有的,将以两个"_"开头的类成员变量或对象变量名前加入"_“+类名,使得基于"__"开始的变量是无法被正常访问的class MyClass: classValue1 = 100 _classValu2 = 200 __classValue3 = 300 def __init__(self

2013-04-27 17:16:03 1247

原创 python知识点总结

2013-4-101) python单件class Singleton(object): _instance = None def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = super(Singleton, cls).__new__(

2013-04-10 15:01:06 1026

原创 python常见函数修饰符总结(不断更新)

Last Update: 2013-4-9欢迎转载[email protected]) @classmethod用classmethod修饰表示这是一个类方法,如果没有用@classmethod修饰,则表示这是一个对象方法,使用时必须与一个对象绑定,如下class MyClass(): def thisIsClassMethod(self):

2013-04-09 21:15:34 10277 2

原创 python的异常处理流程

python里面使用try-except-else-finally来处理异常,流程是:先处理try内的部分,有异常则进入except分支,否则进入else分支,但不管有无异常肯定会进入finally分支。这里结合以前java处理异常的流程,写了几个例子,做一个总结://///////////////////////////////////////////////////////////////

2013-04-05 21:04:36 1142

转载 如何检测CPU是大端还是小端

MSB 最高有效位LSB 最低有效位所谓的大端 值得是最高有效位放在最低地址小端,则是最低有效位放在最低地址#include int main(){ union ut{ short s; char c[2]; }u; if(sizeof(short) == 2) { u.s = 0x0102; fprintf(

2013-03-29 23:18:00 957

原创 C++中不能被继承的类的实现

首先,了解下什么是虚继承-- 为了解决菱形继承的多义性 #include using namespace std;class Animal{public: void foo() { cout "Animal foo"endl; }};class Mammal : public virtual Animal{};class W

2013-03-29 13:08:06 776

原创 C++默认成员函数使用说明

1) 默认构造函数2) 默认析构函数3) 拷贝构造4) 赋值函数5) 缺省取值6) 缺省取值(const)对于后2个,之前还真没注意到是操作符重载,现在记录下:#include using namespace std;class MyClass{public: MyClass(int value) { mValue =

2013-03-28 23:12:51 817

原创 链表合并的递归和非递归方法

两个链表,已经有序排列,现在将其合并并输出新的链表#include using namespace std;#include using std::vector;#include #ifndef _WIN32#include #else#include #endiftemplatestruct Node{public: Node(T value)

2013-03-27 23:40:19 771

原创 求逆序数

输入一个整数,如83721,输出其逆序数12738#include using namespace std;int reverseNumber ( int input ){ int retval = 0; while ( input ) { int lowNumber = input % 10 ;

2013-03-27 21:35:06 904

原创 C++字符串翻转操作

举例:I love cpp翻转后cpp love I 算法: 先翻转整个句子,再翻转每个单词 #include #include void reverseInPlace( char *input, int start, int end ){ char *s = input + start; char *e = input + end; w

2013-03-27 11:35:37 2485

原创 有关C++对象与bool比较时的操作符重载

需要实现operator bool ()的重载。struct MyClass{ explicit operator bool() const { return true; } };如上:写了一个完整的例子#include using namespace std;class MyClass{public: MyClass(int valu

2013-03-25 22:23:57 7898

原创 ACE中的精确定时器

ACE中有一个类,ACE_High_Res_Timer,这里的Res即为Resolution,用OS相关的方法来获取精确的定时器。其中静态方法global_scale_factor的原型为ACE_UINT32 global_scale_factor()打开对应的.cpp,可以看到这个函数在Linux平台下调用的是ACE_High_Res_Timer::get_cpuinfo()

2013-03-25 18:55:22 2254

原创 ACE_Singleton用法

#include #include #include #include #include #include #include class MyClass{public: void foo() { ACE_DEBUG((LM_DEBUG,"foo called\n")); }};

2013-03-25 10:36:35 2614

原创 最大子段和的动态规划法

#include using namespace std;int MaxSumDyn( int array[],int len ){    int sum = 0;    int b = 0;    for ( int i = 0; i     {        if ( b > 0 )        {            b += array[

2013-03-24 19:51:57 1092

原创 大数相加算法

/*author: [email protected]由于GCC,VS的内置数据类型的加法受限于int,long,unsigned long等的精度,则对于大数的加法应采用字符串的形式进行输入和计算。Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job

2013-03-21 11:52:30 5610

原创 水仙花数求解

/*在数论中,水仙花数(Narcissistic number)也称为自恋数、自幂数、阿姆斯壮数或阿姆斯特朗数(Armstrong number),是指一N位数,其各个数之N次方和等于该数。例如153、370、371及407就是三位数的水仙花数,其各个数之立方和等于该数:153 = 13 + 53 + 33。370 = 33 + 73 + 03。371 = 33 + 7

2013-03-20 09:01:07 1046

原创 int溢出的问题

今天,在论坛上看到一个帖http://bbs.csdn.net/topics/390397669?page=1#post-393964523后面有我的回复总结了下 获取与编译器相关的int、char、long的最大值的方法分别为1) 使用头文件 里面分别有关于最大、最小的char 、int、long的值。2) 分别将-1转换成对应的unsigned char

2013-03-19 21:38:33 4089

原创 ACE_Profile_Timer用法

ACE_Profile_Timer的用法ACE_Profile_Timer提供了一个简易的计算资源使用情况的接口使用时声明如下对象:ACE_Profile_Timer timer;timer.start();//....your operationtimer.stop();ACE_Profile_Timer::ACE_Elapsed_Time elapse_ti

2013-03-19 16:51:50 2230

原创 itoa 和 atoi和字符串翻转等操作

#include using namespace std;#include #include //输入"12345",输出对应的int值int myAtoi(const char *number){ int retval = 0; while ( '\0' != *number ) { retval = retval *1

2013-03-19 10:15:31 848

原创 链表翻转的递归和非递归算法

#include #include using namespace std;templatetypename T>struct Node{ Node ( T value ) : mValue(value),mNext(0) { } Node *mNext; T mValue;};templatetypename

2013-03-18 18:44:31 793

原创 字符串翻转

/*字符串翻转是常见笔试面试题,记录下来*/#include #include void reverse( const char *src, char *dest ){ if ( src == 0 ) { return ; } int strLen = strlen(src); while ( strLen

2013-03-18 16:01:24 895

原创 整数划分问题

将一系列正整数表示成一系列正整数之和: n = n1 + n2 + .... + nk   正整数n的一个这种表示方法称为正整数n的一个划分,正整数n的不同划分个数称为正整数n的划分数,记为p(n)例如  正整数6有下面6种不同的划分,分别记为:   6 = 6   6 = 5 + 1   6 = 4+2, 4+1+1   6 = 3+3, 3+2+1,3+1+1+

2013-03-17 22:30:20 760

转载 排列问题

输出数组的所有排列组合项#include using namespace std;#include static int allNumber = 0;templatetypename T>void Perm ( T list[],int k ,int m ){ if ( k == m ) { for ( int i =

2013-03-17 21:49:12 620

原创 c语言中format不同的数据匹配的不同数据格式

C/C++编译时,如果对应的参数类型和格式不匹配,经常会有warning,为了避免warning,我总结了下常见的的数据类型对应的格式,后期会不断丰富数据类型格式int %dlong %ldunsigned long%lulong long %lld或%lliunsigned long long

2013-03-13 22:43:54 1611

原创 树的遍历

#include using namespace std;#include #include using std::stack;templatetypename T>struct Node{ Node(T value):mValue(value),mLeftChild(0),mRightChild(0) { } T mValu

2013-03-13 18:45:50 748

原创 在二元树中找出和为某一值的所有路径

题目:输入一个整数和一棵二元树。从树的根结点开始往下访问一直到叶结点所经过的所有结点形成一条路径。打印出和与输入整数相等的所有路径。例如输入整数22和如下二元树                                             10                                            /    \

2013-03-13 11:32:22 850

原创 vector和dequeue的push_back比较

/*本文比较了vector和dequeue差距,看来对vector使用时,在有大规模数据需要使用push_back时,应该使用reserve来重新设定空间大小。否则,使用vector的每次push_back时,vector会重新释放以前的数据,进行重新拷贝,造成不必要的开销。而dequeue的插入不会引人旧数据的释放,适合大规模数据的拷贝。*/  #include

2013-03-13 10:41:01 1560

原创 在二元树中找出和为某一值的所有路径

题目:输入一个整数和一棵二元树。从树的根结点开始往下访问一直到叶结点所经过的所有结点形成一条路径。打印出和与输入整数相等的所有路径。例如输入整数22和如下二元树                                             10                                            /    \

2013-03-12 00:10:44 748

原创 二叉树的层次遍历

8 / \ 6 10 / \ / \ 5 7 9 11 层次遍历输出结果: 8,6,10,5,7,9,11#include using std::deque;#include using namespace std;templatetypename T>struct TreeNode{publ

2013-03-11 22:31:24 839

转载 emacs查找和替换

KeyMeaningC-sSearchM-%ReplaceC-M-%Replace RegexpC-s tells Emacs to start an interactive search. Type a search term at the prompt, and Emacs will move the cursor to th

2013-03-11 09:37:22 800

原创 八皇后问题回溯算法

#include #include using namespace std;#include using std::vector;#include #include #define QUEENS 8int iCount = 0;int Site[QUEENS];void Queue(int n);void Print();bool isVal

2013-03-10 22:02:13 799

转载 值得参考的几本算法书

有些看过,有些没看过,先记录下。算法导论 Thomas H.Cormen算法设计 Jon KleinbergC算法,java算法 Robert Sedgewick图论导引 Douglas B.west计算理论导引 Michael Sipser图论及其算法 殷剑宏

2013-03-06 23:27:27 769

原创 exclude方式的拷贝和exclude方式的删除

Linux下往往需要进行文件的拷贝和删除操作,而拷贝和删除时往往需要有些exclude的操作,如exclude 某个特定的目录使用格式rsync -av -exclude=/thepathtobeexcluede source dest

2013-03-06 11:47:27 1225

原创 句子翻转的STL实现

字符串翻转的例子输入如 A fox has jumped into the river输出为 river the into jumped has fox A#include #include using std::string;#include using std::vector;#include using name

2013-03-05 17:42:28 807

转载 python里有关static变量的实现方法

文章写的不错,直接转载了http://stackoverflow.com/questions/279561/what-is-the-python-equivalent-of-static-variables-inside-a-function

2013-03-02 21:27:24 6719

原创 有关python的运行时参数PYTHONUNBUFFERED的用法

发现PYTHON的运行环境中有一个参数为PYTHONUNBUFFERED查了下其用法,并结合以前的一些编程知识,对这一参数总结如下,首先,对于stderr,标准里规定是无缓冲的,而对于stdout,UNIX标准里规定是行缓冲的对于下面的python代码if __name__ == "__main__":    import sys    sys.stdout.write("

2013-03-02 12:19:42 14545 1

转载 程序员之气质培养

哈哈,让我一下子想起了经典的黑客帝国,那才叫程序员 原帖 http://blog.csdn.net/k122769836/article/details/8621093一:沉稳     (1)不要随便显露你的情绪。     (2)不要逢人就诉说你的困难和遭遇。     (3)在征询别人的意见之前,自己先思考,但不要先讲。     (4)不要一有机会就唠叨你的不满。

2013-03-02 09:13:16 1441

原创 gdb调试死锁线程

/** 死锁调试 1) -g参数 2) attach 3) info threads 4) thread + number切换到对应的线程或thread apply all bt全部设置断点*/#include #include #include void *workThread( void *arg ){    pthread_mut

2013-02-26 18:18:16 4150

原创 sublime text2 设置空格可视化

Prefences -> Settings -> Default将原来的"draw_white_space": "selection",修改为"draw_white_space": "all",用空格代替tab// Set to true to insert spaces when tab is pressed "translate_tabs_to_spac

2013-02-25 09:03:31 20548 3

空空如也

空空如也

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

TA关注的人

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