摘要: #include<stdio.h> #include<stdlib.h> typedef struct treenode{ int data; struct treenode *lchild,*rchild; }treenode,*tree; //查看一个结点的值 void visit(treeno 阅读全文
posted @ 2021-11-15 19:40 大耿2844 阅读(527) 评论(0) 推荐(0)
摘要: #include<iostream> #include<string> using namespace std; void test1(){ string s1;//默认构造 创建一个空字符串 cout<<s1<<endl; const char *s2="hello c++";//字符串初始化(c 阅读全文
posted @ 2021-01-27 19:16 大耿2844 阅读(91) 评论(0) 推荐(0)
摘要: #include<iostream> #include<queue>//队列容器 #include<string> using namespace std; class person{ public: person(string name,int age){ m_name=name; m_age=a 阅读全文
posted @ 2021-01-27 17:53 大耿2844 阅读(225) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; //顺序存储的循环队列 const int maxsize=5; class cir_queue{//Circular queue 循环队列 public: int data[maxsize]; int front; i 阅读全文
posted @ 2021-01-27 17:15 大耿2844 阅读(195) 评论(0) 推荐(0)
摘要: 数据结构中的链栈可以由c++STL的stack容器实现 以下是常见函数: #include<iostream> #include<stack> using namespace std; /* stack是一种先进后出的数据结构 只有一个出口 栈中只有顶端的元素才可以被外界使用,因此栈不允许有遍历行为 阅读全文
posted @ 2021-01-24 17:48 大耿2844 阅读(65) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; //栈的顺序存储结构--顺序栈 //栈是一种特殊的线性表 const int maxsize=100; class s_stack{//Sequential stack 顺序栈 public: s_stack(const 阅读全文
posted @ 2021-01-24 17:11 大耿2844 阅读(94) 评论(0) 推荐(0)
摘要: #include<iostream> #include<list>//类似于双向循环链表 using namespace std; void show(list<int>l){//输出容器list中的内容 for(list<int>::iterator it=l.begin();it!=l.end( 阅读全文
posted @ 2021-01-23 17:27 大耿2844 阅读(152) 评论(0) 推荐(0)
摘要: 数据结构中的双向循环链表可以用c++STL库中的list容器代替. 以下是网上资料: 1.关于list容器 list是一种序列式容器。list容器完成的功能实际上和数据结构中的双向链表是极其相似的,list中的数据元素是通过链表指针串连成逻辑意义上的线性表,也就是list也具有链表的主要优点,即:在 阅读全文
posted @ 2021-01-23 11:42 大耿2844 阅读(147) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; //循环单链表 class point{//结点类 public: int data; point *next; }; class line{//单链表 public: int length; point *head; 阅读全文
posted @ 2021-01-22 15:07 大耿2844 阅读(87) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; //单链表 class point{//结点类 public: int data; point *next; }; class line{//单链表 public: int length; point *head; li 阅读全文
posted @ 2021-01-21 20:52 大耿2844 阅读(45) 评论(0) 推荐(0)