C++
文章平均质量分 79
hi_software
这个作者很懒,什么都没留下…
展开
-
linux信号机制
1.signal 是比较传统的linux函数,存在缺陷,表现在信号不可靠(丢失...), 绝对不要使用(linux保留该函数只是为了兼容) eg: 通常使用signal(SIGPIPE, SIG_IGN)用以忽略 sigpipe,但是在多线程中只在主线程设置却是不够的,一种解决方法是在每个线程都设置, 根本原因在于如果一个sigpipe正在处理的话,新来的sigpipe信号会采用默认处理方原创 2016-11-22 22:55:29 · 527 阅读 · 0 评论 -
Python调用C++
1.C++开发使用Python,首先需要在Python中安装依赖包,对于centos可以使用yum search python-dev,之后采用yum install 安装。 2.安装python,用源码安装,经过./configure,make,make install后生成libpython2.7.a。 3.可能会需要一些其他的库,eg: gcc Test.cpp -I /usr/in转载 2015-09-29 14:35:33 · 577 阅读 · 0 评论 -
马的遍历(多方案)
//此解法的重点在于,通过一个变量取余使得具有相同路数的可能走另一条路,优先级变化。 #include #define INF 100 int board[8][8]; int start; int mover[] = {-2, -1, 1, 2, 2, 1, -1, -2}; int movec[] = { 1, 2, 2, 1,-1,-2, -2, -1}; int n转载 2013-03-24 20:22:12 · 683 阅读 · 0 评论 -
C++实现双精度浮点数四则运算
#include #include #include #include using namespace std; class Data { public: char Op; double Number; }; void getEnter( char Enter[100] ) { cin.getline(Enter,100); } int judgeOp(转载 2012-12-11 18:42:22 · 6372 阅读 · 2 评论 -
STL实现括号匹配
//括号匹配,利用STL中的栈来实现,对(,[,{入栈操作,其余采用出栈操作 #include #include using namespace std; int judge( char a ) { switch (a) { case '[': case '{': case '(': return 1; default: return 0; }原创 2012-12-09 21:47:01 · 1919 阅读 · 0 评论 -
两数组中的相同元素
//找两个数组中的相同元素,首先对两数组分别排序 #include int Same[20]; int SameElement(int Array1[20],int Array2[20]); void quickSort(int Array[20],int left,int right); void main() { int Array1[20] = {1,21,2,22,3原创 2012-10-11 23:03:17 · 735 阅读 · 0 评论 -
指针与引用实现多态
引用是除指针外另一个可以产生多态效果的手段。 #include using namespace std; class A { public: virtual void print() { cout } }; class B:public A { public: void print() { cout } }; void main() {原创 2012-09-13 12:37:23 · 3666 阅读 · 0 评论 -
STL学习小结
转载自:http://blog.csdn.net/byxdaz/article/details/4633826 STL就是Standard Template Library,标准模板库。这可能是一个历史上最令人兴奋的工具的最无聊的术语。从根本上说,STL是一些“容器”的集合,这些“容器”有list, vector,set,map等,STL也是算法和其它一些组件的集合。这里的“容器”和算法的集转载 2012-10-02 13:06:22 · 746 阅读 · 0 评论 -
不用中间变量交换两个数的陷阱
在面试题中会看到这样的代码: int a = 1; 或 int a = 1; int b = 2;原创 2012-10-04 07:46:14 · 729 阅读 · 1 评论 -
结构体与类
结构体与类 C的结构体不含成员函数。C++的类既能包含数据成员,又能包含成员函数。 结构体与类的区别(C++): 类定义中默认情况下的成员是private的,结构定义中默认情况是public; 在类中定义: 定义不能在类的头文件中,因为这样会被编译多次。 内联函数包含在头文件中是允许的(并且通常都是),因为内联函数在源程序原地展开.大多数建置环境在编译过程中inlining,而原创 2012-09-12 20:52:18 · 261 阅读 · 0 评论