
C/C++
iteye_19330
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
堆排序代码实现
void heap_adjust(int a[],int i,int size){ int temp; int j = i*2 +1; if(i<=size/2-1){ //保证其为非叶子节点----这里请注意 if(j+1<size&&a[j]<a[j+1]){ //找出子节点中值最大的 j++; } if(a...原创 2012-07-01 23:37:42 · 88 阅读 · 0 评论 -
重复删除指针
#include <iostream> using namespace std; class Base{ public: void f(){ cout<<"base"<<endl; } private: int a; }; int main(){ Base* b = new Base; delete b; dele...原创 2012-07-27 22:10:14 · 272 阅读 · 0 评论 -
继承关系中的早绑定
#include <iostream> using namespace std; class Base{ public: void f(){ cout<<"base"<<endl; } }; class Derived:public Base{ public: void f(){ cout<<"derived...原创 2012-07-27 09:00:48 · 136 阅读 · 0 评论 -
has virtual functions but non-virtual destructor
#include <iostream> using namespace std; class based{ public: based(){ } ~based(){ cout<<"flag 1"<<endl; } virtual void f(){ cout<<"ok1"<<endl;原创 2012-07-14 13:36:47 · 7068 阅读 · 0 评论 -
二叉树的中序遍历
#include <iostream> #include <stack> using namespace std; struct node{ int data; struct node* lchild; struct node* rchild; }; typedef struct node Node; void inOrderTraverse(Nod...原创 2012-07-13 10:04:51 · 129 阅读 · 0 评论 -
两个有序数组求中位数的O(logn)算法
#include <iostream> using namespace std; int get_median(int a[],int begin1,int end1,int b[],int begin2,int end2,int k){ if(begin1>end1){ //在数组A中无法找到 return get_median(b,begin2,end2,...原创 2012-07-13 00:16:55 · 651 阅读 · 0 评论 -
智能指针的简易实现
#include <iostream> using namespace std; class smart_count{ private: int use_count; public: smart_count(int c=0):use_count(c){ } ~smart_count(){} int addref(){ return ++us...原创 2012-07-12 16:26:52 · 105 阅读 · 0 评论 -
C++中把多维数组传递给函数可使用模版的办法
#include <iostream> using namespace std; template<int m,int n> void print(int a[m][n]){ for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cout<<a[i][j]<<" "; ...原创 2012-07-11 23:30:53 · 204 阅读 · 0 评论 -
图的广度深度遍历(邻接矩阵)
#include <iostream> #include <queue> #include <algorithm> #include <stack> using namespace std; int a[5][5]={{0,1,0,1,0},{1,0,1,0,1},{0,1,0,1,1},{1,0,1,0,0},{1,0,1,0,0}...原创 2012-07-11 23:25:41 · 373 阅读 · 0 评论 -
使用linux函数模拟HTTP 请求过程
非常好的参考资料 1.HTTP 协议资料 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2 2.使用telnet模拟浏览器访问网页 http://pcwanli.blog.163.com/blog/static/4531561120091115105240732/ #include "apue.h" ...原创 2012-08-01 21:50:36 · 440 阅读 · 0 评论