- 博客(17)
- 资源 (3)
- 收藏
- 关注
原创 链队列类
/* 链队列 */ #include #include using namespace std; template class LinkQueue; template class Node { private: friend class LinkQueue; Node *next; T data; public:
2011-12-28 13:35:55 398
原创 链栈类
/* 链栈 */ #include #include using namespace std; template class LinkStack; template class Node { private: friend class LinkStack; Node *next; T data; public:
2011-12-28 00:20:47 406
原创 顺序栈类
/* 顺序栈 */ #include #include using namespace std; template class SqStack { private: int maxlen; T *elem; int top; public: SqStack() { top=-1; } SqSta
2011-12-24 22:48:09 485
原创 双向循环链表类
/* 双向循环链表(与单链表没有太大的区别) */ #include #include using namespace std; template class DlList; template class DlNode //节点类 { private: DlNode *prior,*next; T data; friend c
2011-12-23 00:54:26 594
原创 静态链表类
/* 静态链表类 */ #include #include using namespace std; template class StList { private: struct Tnode { int cur; T data; }; int sl,av; //av自由
2011-12-22 23:48:25 691
原创 单链表类
/* 链表类 */ #include #include using namespace std; template class Linklist; template class Node { private: friend class Linklist; Node *next; T data; public:
2011-12-20 15:08:34 503
原创 顺序表类
/* 顺序表类(查找、插入与删除的实现) */ #include #include using namespace std; template class Sqlist { private: int curlen; int maxlen; T *elem; public: Sqlist( T *a,int n,
2011-12-20 13:33:29 631
原创 堆排序
/* 堆排序 */ #include #include using namespace std; void shift( int *a,int m,int n ) { int i,j,x,temp; i=m , j=2*i ; x=a[m]; while( j<=n ) { if( ja[j+1] ) j=j+1;
2011-12-19 13:46:51 404
原创 归并排序
/* 归并排序 */ #include #include using namespace std; void merg( int *a,int sta,int mid,int end ) { int i,j,k; int *b=new int[end-sta+1]; k=0 , i=sta , j=mid ; while( i<mid && j<=end )
2011-12-18 23:53:25 430
原创 二叉排序树的插入与查找实现
/* 二叉排序树的插入与查找实现 */ #include #include using namespace std; template class BSTree; template class BTreeNode { private: BTreeNode *lchild; BTreeNode *rchild; T data;
2011-12-18 11:39:36 841
原创 二分查找的递归与非递归算法
/* 二分查找的递归与非递归算法 */ #include #include using namespace std; bool bisrch( int low,int high,int v,int *text ) //递归写法 { int i,mid; mid=( low+high )/2; if( low>high ) return false; if( v
2011-12-18 11:35:10 6387
原创 直接选择排序
/* 直接选择排序 */ #include #include using namespace std; void selesort( int *a,int n ) { int temp,i,j,mini,mark; for( i=0;i<n;i++ ) { mini=a[i]; for( j=i+1;j<n;j++ )
2011-12-18 11:33:16 492
原创 快速排序
/* 快速排序 */ #include #include using namespace std; void qkpass( int *r,int sta,int end,int &i ) { int j,x; i=sta , j=end , x=r[i]; while( i<j ) { while( i<j && x<=r[j] ) j--
2011-12-18 11:32:47 547
原创 冒泡排序
/* 冒泡排序 */ #include #include using namespace std; void bubbsort( int *a,int n ) { int i,j,temp; bool flag; for( i=0;i<n;i++ ) { flag=true; for( j=1;j<n-i;j++ )
2011-12-18 11:32:18 411
原创 图的深度、广度优先搜索(邻接矩阵)
邻接矩阵这个写的多了。。 /* 图的深度、广度优先搜索(邻接矩阵存储) */ #include #include #include #include using namespace std; class Graph { private: int adj[100][100]; int max; bool *visit;
2011-12-15 00:00:44 587
原创 图的深度、广度优先搜索(邻接表)
越发的发现,自己对链表的不熟悉。写dfs、bfs写了无数次,结果用链表写的时候居然迟疑了。。 多多加强对链表的运用啊! /* 图的深度、广度优先搜索(邻接表存储) */ #include #include #include #include using namespace std; struct ArcNode { ArcNode *nextarc;
2011-12-14 20:04:33 607
原创 建图(Graph类的插点和插边实现)
好吧。。。N久没写过代码了。。。。 最近忙着复习期末加六级再加上坑爹的游戏休闲,什么ACM都木有碰啊。。坑爹。。 决定这两个星期把数据结构书上的代码都敲一遍。 #include #include using namespace std; struct ArcNode { ArcNode *nextarc; int id; int weight; }; struct
2011-12-14 14:27:57 935
瑞士军刀NC
2011-10-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人