
c++数据结构
文章平均质量分 58
shenqi67
这个作者很懒,什么都没留下…
展开
-
单向循环链表
// 单向循环链表.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include#include "CLinkList.h"using namespace std;int _tmain(int argc, _TCHAR* argv[]){int a[]={1,2,3,4,5};int n=5;/*测试空链表*原创 2012-03-29 23:21:36 · 609 阅读 · 0 评论 -
约瑟夫环实验报告
// 约瑟夫环.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include#include "LinkList.h"using namespace std;templatevoid Josephus(Node *first, int n){ Node *temp = NULL; cout << "离座顺序: "; while(fir原创 2012-04-08 17:28:29 · 7026 阅读 · 0 评论 -
链栈
// 链栈.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include "LinkStack.h"#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ LinkStack stack; int i; cout << "请输入入栈元素: "; cin >>原创 2012-04-09 18:56:45 · 366 阅读 · 0 评论 -
顺序表和链表的比较
一,时间性能的比较顺序表由数组实现,是一种随机存取结构,对表中任意节点存取操作时间复杂度为O(1)。而查找链表的节点,须从头指针开始沿链扫描,平均时间复杂度为O(N).因此,若线性表的操作主要是查找,很少进行插入或删除操作,采用顺序比较合适。 对于链表,对某个节点进行插入删除操作只需修改指针,无需大量移动元素,平均时间复杂度为O(1)。而顺序表在插入或删除时,需要大量移动数据元素,原创 2012-04-06 23:21:25 · 1882 阅读 · 0 评论 -
创建类时类名不能含有模版参数
#pragma oncetemplateclass Node //应该为class Node,否则{public: T data; Node *lch; Node *rch; Node():lch(NULL),rch(NULL){} //Node *Search(Node *R,T key);};templateNode* Search(Node *R,T key)原创 2012-04-21 10:05:11 · 2240 阅读 · 0 评论