![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
Joey_PRC
离优秀还差着十万八千里
展开
-
统计字符串中各字符出现的次数
//C++ file#include<vector>#include<cstring>using namespace std;int main(int argc, char *argv[]){ vector<char> s1; int ss1[20]; char test[] = "aaaabbcccdddddd"; ...原创 2018-08-30 15:03:15 · 776 阅读 · 0 评论 -
实现字符串中所有子串w用另一个字符串x来替换,w和x可以长度不同。
//C++ file#include<cstring>using namespace std;void Getnext(char s1[], int next[]){ int j=0,k=-1; next[0]=-1; int len = strlen(s1); while(j<len) { if(k==-1 ...原创 2018-08-30 15:03:58 · 370 阅读 · 0 评论 -
实现字符串中所有子串w用另一个字符串x来替换,w和x可以长度不同。
//C++ file#include<cstring>using namespace std;void Getnext(char s1[], int next[]){ int j=0,k=-1; next[0]=-1; int len = strlen(s1); while(j<len) { if(k==-1 ...原创 2018-08-30 15:04:04 · 243 阅读 · 0 评论 -
用十字链表示稀疏矩阵,并实现稀疏矩阵的建立,输出,加法,乘法等。
新手学习数据结构状态,有任何问题和建议烦请指出,共同交流,谢谢~//C++ fileusing namespace std;typedef int Elemtype;struct Node{ int row; int col; Node *down; Node *right; union { Node *next...原创 2018-08-30 15:05:28 · 1363 阅读 · 0 评论 -
二叉排序树查找
#include<iostream>using namespace std;typedef int KeyType;struct BstNode{ KeyType key;// char ch; BstNode *lch, *rch;};class Bstree{public: Bstree(){root = nullptr;} ...原创 2018-09-10 22:26:47 · 283 阅读 · 0 评论 -
链地址法实现hash表,查找关键字,输出关键字
#include<iostream>using namespace std;typedef int KeyType;const int MAXSIZE = 100;struct ElemNode{ KeyType key; ElemNode *next;};class LinkHash{private: ElemNode *ht; ...原创 2018-09-15 11:12:57 · 1008 阅读 · 1 评论 -
建立顺序表,实现顺序查找,折半查找,递归折半查找
#include<iostream>using namespace std;const int MAXSIZE = 100;typedef int KeyType;struct datanode{ KeyType key;// char ch;};class Sqtable{private: datanode r[MAXSIZE]; ...原创 2018-09-15 11:14:47 · 4140 阅读 · 0 评论 -
顺序表存储实现冒泡排序,选择排序,插入排序,希尔排序,基数排序
#include<iostream>using namespace std;const int MAXSIZE = 100;typedef int ElemType;struct Data{ ElemType key;// int shu; int point;};//Data ar[MAXSIZE], br[MAXSIZE];int yx(...原创 2018-09-15 11:17:26 · 2657 阅读 · 0 评论 -
动态链表实现基数排序,插入排序
#include<iostream>using namespace std;struct Node{ int key; Node *next; int yx(int i);};class ListNode{private: Node *root; int n;public: ListNode(); ~ListN...原创 2018-09-15 11:18:18 · 409 阅读 · 0 评论 -
测试字符串是否为回文字符串
//C++ file#include<cstring>using namespace std;int main(int argc, char *argv[]){ char s1[] = "abcdedcba"; char s2[] = "aabb"; int p1 = strlen(s1); int p2 = strlen(s2); ...原创 2018-08-30 15:02:27 · 449 阅读 · 0 评论 -
矩阵存储实现图,广度优先遍历
#include<SqQueue.h>const int MaxVertices = 10;const int MaxWeight = 32767;class AdjMWGraph{private: int Vertices[MaxVertices]; int Edge[MaxVertices][MaxVertices]; int numE; ...原创 2018-09-04 21:56:50 · 483 阅读 · 0 评论 -
无向图,邻接链表存储,prim算法实现最小生成树,深度优先搜索,广度优先搜索。
仅实现算法过程,对输入未监测//#include<iostream>#include<SqQueue.h>#include<climits>//using namespace std;const int MaxVectices = 100;typedef int VerT;typedef int DisT;//----------------...原创 2018-09-04 20:01:09 · 942 阅读 · 0 评论 -
实现顺序表逆置,在原数组上操作
//C++ file#include <stdlib.h>using namespace std;int main(int argc, char const *argv[]){ int x[5] = {1, 2, 3, 4, 5}; int len = sizeof(x); for (int i = 0; i < len; i++) ...原创 2018-08-28 16:43:49 · 1377 阅读 · 0 评论 -
建立单链表,实现链表指定位置插入、删除,实现2个链表连接,实现Josephu问题
建立单链表,实现链表指定位置插入、删除,实现2个链表连接,实现Josephu问题//C++ file#include <iostream>#include <string>#include <string.h>using namespace std;struct ElemType { char name[10]; int ...原创 2018-08-28 16:45:08 · 739 阅读 · 0 评论 -
单链表,插入删除,连接等功能。
//C++ file#include <stdio.h>#include <iostream>#include <string>#include <string.h>using namespace std;struct ElemType { char name[10]; int tel;};struct Nod...原创 2018-08-28 16:45:52 · 125 阅读 · 0 评论 -
火车调度问题
假定有编号为ABCD的4辆列车,顺序开进一个栈式结构的站台,请写出开出车站站台的列车顺序有几种 1. 假定有编号为A、B、C、D的4辆列车,顺序开进一个栈式结构的站台,请写出开出车站站台的列车顺序有几种(注释:每一列车由站台开出时均可进站,出站,但不允许出站后回退)?写出所有可能的序列。实现n列火车的调度问题//C++ file#include <vector>#inc...原创 2018-08-28 16:48:02 · 2588 阅读 · 0 评论 -
链表栈:取栈顶元素和置栈空 C++实现
//C++ file#include<string>#include<string.h>using namespace std;struct Elem{ char name[10]; Elem *next;};class SqBT{private: Elem *top;public: SqBT(); ~Sq...原创 2018-08-28 16:50:11 · 1986 阅读 · 0 评论 -
十进制转八进制
//C++ fileusing namespace std;void trans10_8(int x){ int a = x/8; int b = x%8; if(a < 1) cout<<x; else //if(a >= 1) { cout<<b; tran...原创 2018-08-28 16:50:48 · 414 阅读 · 0 评论 -
字符串连接
//C++ file#include<cstring>using namespace std;int main(int argc, char *argv[]){ char s1[] = "aaa"; char s2[] = "bbb"; char *p1 = s1, *p2 =s2; int size = strlen(s1)+strlen...原创 2018-08-28 16:51:56 · 101 阅读 · 0 评论 -
置换字符串第pos位置开始的num个元素
//C++ file#include<cstring>#include<string.h>using namespace std;int main(int argc, char *argv[]){ char s1[] = "abcdefg"; char s2[] = "mmm"; int i,pos,num;// cout<...原创 2018-08-28 16:52:48 · 586 阅读 · 0 评论 -
链表存储实现二叉树,实现二叉树先根,中根,后根递归非递归遍历算法
栈模板#include<iostream>using namespace std;template<class T>class SqStack{public: SqStack(int s=30); ~SqStack(){delete[] elem;} void Push(T item); T Pop(); T GetT...原创 2018-09-01 17:45:36 · 1307 阅读 · 0 评论 -
数据结构基础理论学习完成
从8月17日开始,至9月15日,时间1个月,学习数据结构基础理论,完成所有课后习题,基本实现书中所有算法的C++代码,linux平台,搭建自己习惯的vim,gdb调试。学习内容:1. 线性表:顺序存储,链表存储(单链表,循环链表,双向链表等)。2. 栈和队列:栈的定义,栈的顺序存储结构,栈的链表存储及应用;队列的顺序存储,链存储及实现。3. 串:串的定长顺序/堆/链存储...原创 2018-09-15 11:40:38 · 195 阅读 · 0 评论