![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
姜饼糖糖要努力
姜大诺的作业博客
展开
-
数据结构 顺序栈进行进制转换
SeqStack.h 数据结构 顺序栈进行进制转换 #ifndef SeqStack_H #define SeqStack_H const int StackSize=10; template//定义模板类 class SeqStack { public: SeqStack(); ~SeqStack(){ } void Push(DataType x);//将元素x入栈 DataTyp转载 2017-11-16 18:53:28 · 1366 阅读 · 0 评论 -
数据结构 约瑟夫环
#include using namespace std; const int MAX=100; void Josephus(int m,int n){ int r[MAX]; //存1~m int i,l,count; for(int i=0;i<m;i++){ //给数组r赋值 r[i]=i+1; } count=0;转载 2017-12-08 10:55:25 · 947 阅读 · 0 评论 -
数据结构 插入排序
#include//引入输入输出流 #include//使用库函数srand和rand #include//使用库函数time using namespace std; const int Max=10; void Creat(int r[],int n); void InsertSort(int r[],int n); int main() { int a[Max+1]={0},b[Max转载 2017-12-15 10:41:41 · 193 阅读 · 0 评论 -
数据结构 希尔排序
#include//引入输入输出流 #include//使用库函数srand和rand #include//使用库函数time using namespace std; const int Max=10; void Creat(int r[],int n); void ShellSort(int r[],int n); int main() { int a[Max+1]={0},b[Max+转载 2017-12-15 10:42:15 · 168 阅读 · 0 评论 -
数据结构 拓扑排序
ALGraph.h #ifndef ALGraph_H #define ALGraph_H const int MaxSize=10; struct ArcNode { int adjvex; ArcNode*next; }; template struct VertexNode { DataType vertex; ArcNode *firstedge; }; template cl转载 2017-12-01 11:33:13 · 233 阅读 · 0 评论 -
数据结构 快速排序冒泡排序
#include #include #include//使用库函数srand和rand函数 using namespace std; const int Max=10; void Creat(int r[],int n); void BubbleSort(int r[],int n);//起泡排序 int Partition(int r[],int first,int end) ;//一次划分转载 2017-12-21 21:32:28 · 262 阅读 · 0 评论 -
邻接矩阵
MGraph.h #ifndef MGraph_H//避免包含MGraph.h的头文件 #define MGraph_H const int MaxSize=10;//图中最多的顶点 template class MGraph { public: MGraph(DataType a[],int n,int e);//建立n个顶点 e条变 ~MGraph(){ } void DFS转载 2017-11-24 11:33:04 · 1699 阅读 · 0 评论 -
数据结构 递归
BiTree.h#ifndef BiTree_H #define BiTree_H//避免重复包含BiTree的头文件 //定义二叉链表的节点 struct BiNode { char data;//假设二叉树的结构类型为char型 BiNode *lchild,*rchild; } ; class BiTree { public: BiTree() { root=Creat(root); }转载 2017-11-16 19:00:14 · 174 阅读 · 0 评论 -
数据结构 幻方
栀虞 11:15:33 #include"stdio.h" #include"math.h" //定义一个二维数组存放数据,大小根据测试的阶数确定 void square(int a[5][5],int n) { int i,j; for(i=0;i<n;i++) { for(j=0;j<n;j++) { a[i][j]=0; } } int iT,jT;转载 2017-11-16 18:58:37 · 755 阅读 · 0 评论 -
数据结构 单链表的实现
建立新文件 LinkList.cpp #include using namespace std; #include"LinkList.h" template LinkList::LinkList() { first=new Node; first->next=NULL; } template LinkList::LinkList(DataType a[],int n) { Node*转载 2017-11-16 18:37:19 · 248 阅读 · 0 评论 -
数据结构 线性表的顺序结构
打开c++ 点击文件 选择建立项目 点击Console Application 项目改为SeqList 建立第一个文件头改为SeqList.cpp #include #include"SeqList.h" using namespace std; template SeqList::SeqList(DataType a[],int n) { if(n>MaxS转载 2017-11-16 18:26:51 · 172 阅读 · 0 评论 -
数据结构 数组排序
#include using namespace std; void SelectSort(int a[],int n)//选择排序法 { for(int i=0; i<n-1; i++) { int index=i;//定义index记录找到的较小值的位置 for(int j=i+1; j<n; j++) { if(a[j]<a[index])//寻找无序区内的最小值转载 2017-11-16 18:24:05 · 381 阅读 · 0 评论 -
数据结构 srand用法
srand((unsigned)time(NULL))是初始化随机函数种子: 1、是拿当前系统时间作为种子,由于时间是变化的,种子变化,可以产生不相同的随机数。 计算机中的随机数实际上都不是真正的随机数,如果两次给的种子一样,是会生成同样的随机序列的。 所以,一般都会以当前的时间作为种子来生成随机数,这样更加的随机。 2、使用时,参数可以是unsigned型的任意数据,比如srand转载 2017-12-08 10:59:42 · 349 阅读 · 0 评论