数据结构
白木相逸
这个作者很懒,什么都没留下…
展开
-
矩阵
数组元素循环右移 /* 【问题描述】设计算法将含有n个元素的数组A的元素A[0...n-1]循环右移m位。 【输入形式】输入一位数组元素 m的值 【输出形式】输出循环右移m位后的一位数组 【样例输入】 2 1 4 5 8 3 2 【样例输出】 8 3 2 1 4 5 2021/4/19 */ #include <iostream> const int MaxSize=100; using namespace std; void Rotate(int(&a)[Max原创 2021-04-21 19:32:41 · 365 阅读 · 0 评论 -
顺序串
s串中含t串的个数 /*【问题描述】设计算法实现求s串中所含t串的个数。 【输入形式】输入s串 和t串 【输出形式】输出s中含有t的个数 【样例输入】aaabaab ab 【样例输出】2 2021/4/10 */ #include <iostream> using namespace std; const int MaxSize=100; class SqStringClass { char *data; int length; public:原创 2021-04-21 19:25:20 · 278 阅读 · 0 评论 -
链串
串相等 /* 【输入形式】输入 两个字符串 【输出形式】输出判断结果 是否相等 【样例输入】aaab aaac 【样例输出】0 2021/4/10 */ #include <iostream> using namespace std; struct LinkNode { char data; LinkNode*next; }; class LinkStringClass { LinkNode *head; public: Lin原创 2021-04-21 19:16:43 · 256 阅读 · 0 评论 -
队列
非循环队列 基本成员函数 #include <iostream> #define MaxSize 100 using namespace std; template<typename T> class SqQueueClass { T *data; int front,rear; public: SqQueueClass(); ~SqQueueClass(); bool QueueEmpty(); bool enQueue(T .原创 2021-04-21 16:50:04 · 615 阅读 · 0 评论 -
链栈
链栈 基本成员函数 //单链表实现 初始时:head->next==NULL //优点:不需要考虑栈满上溢出的情况 //栈空:head->next==NULL #include <iostream> using namespace std; //单链表实现 初始时:head->next==NULL //优点:不需要考虑栈满上溢出的情况 //栈空:head->next==NULL template<typename T> struct LinkStack原创 2021-04-21 16:41:11 · 130 阅读 · 0 评论 -
顺序栈
顺序栈 基本成员函数 //顺序栈 栈顶指针初始化 top==-1 //栈空:top==-1 //栈满:top==MaxSize-1 #include <iostream> #define MaxSize 100 using namespace std; //顺序栈 栈顶指针初始化 top==-1 //栈空:top==-1 //栈满:top==MaxSize-1 template<typename T> class SqStackClass { T*data; .原创 2021-04-21 16:38:40 · 307 阅读 · 0 评论 -
双链表
双链表x变成y /* 【问题描述】有一个双链表L,设计一个算法将其中所有值为x的结点值替换为y。 【输入形式】输入双链表元素值 x的值 y的值 【输出形式】输出替换后的双链表元素值 【样例输入】2 3 2 5 6 2 9 2 1 【样例输出】1 3 1 5 6 1 9 【样例说明】异常情况说明,如果L中没有x,输出“error” 2021/3/27 */ #include <iostream> using namespace std; te原创 2021-04-21 16:33:28 · 327 阅读 · 0 评论 -
单链表
单链表 基本成员函数 + void Sort();//将单链表递增排序 bool DelMaxNextNode(LinkListClass<T>&L);//删除最大结点的后一个 int Findlast(T x);//查找最后一个值为x结点的逻辑序号 void Reverse(); //单链表 #include <iostream> using namespace std; template <typename T>...原创 2021-04-21 16:30:09 · 630 阅读 · 0 评论 -
顺序表
顺序表 基本成员函数 &确定最小元素的逻辑位序 void类型的简易版(不考虑失败情况)删除所有x #define MaxSize 20 #include<iostream> using namespace std; template<class T> class SqListClass //顺序表类模板 { T *data; int length; public: SqListClass();//构造函...原创 2021-04-21 16:00:15 · 257 阅读 · 0 评论