![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
瑞格专用
本专栏提供瑞格系统数据结构习题个人解答,只是一个答案的体现,也没有优化,注解等详细解读,单纯的可以ac而已,大家觉得有用就粘到本地编译器看一下,没用就关了就好。
喝泉水的泉
这个作者很懒,什么都没留下…
展开
-
8545 直接插入排序
#include <iostream>#include<bits/stdc++.h>using namespace std;void InsertSort(int *a,int length){ int j; for(int i=1;i<length;i++){ int t=a[i]; for(j=i-1;j>=0;j--){ if(t<a[j]){原创 2020-12-24 19:06:11 · 84 阅读 · 1 评论 -
8546 冒泡排序
#include <iostream>#include<bits/stdc++.h>using namespace std;int main(){ int data[100]; int x,i=1,flag; int len=0; cin>>x; while(x){ data[i++]=x; cin>>x; } len=i-1; for(int i=1;i原创 2020-12-24 19:05:30 · 100 阅读 · 1 评论 -
8547 希尔排序
#include <iostream>#include<bits/stdc++.h>using namespace std;void ShellInsert(int a[],int dt,int length){int t,j;for(int i=dt;i<length;i++) if(a[i]<a[i-dt]){ t=a[i]; for(j=i-dt;j>=0&&a[j]>t;j=j-dt)原创 2020-12-24 19:04:26 · 116 阅读 · 1 评论 -
8548 简单选择排序
#include <iostream>#include<bits/stdc++.h>using namespace std;int main(){ int data[100]; int x,i=1,flag; int len=0; cin>>x; while(x){ data[i++]=x; cin>>x; } len=i-1; for(int i=1;i原创 2020-12-24 19:02:38 · 125 阅读 · 1 评论 -
8549 快速排序
#include <iostream>#include<bits/stdc++.h>using namespace std;void HeapAdjust(int *a,int s,int length){ int t=a[s]; for(int i=2*s;i<=length;i=i*2){ if(i+1<=length&&a[i]<a[i+1]) i=i+1; if(t>原创 2020-12-24 19:01:47 · 125 阅读 · 1 评论 -
8550 堆排序算法
#include <iostream>#include<bits/stdc++.h>using namespace std;void HeapAdjust(int *a,int s,int length){ int t=a[s]; for(int i=2*s;i<=length;i=i*2){ if(i+1<=length&&a[i]<a[i+1]) i=i+1; if(t>原创 2020-12-24 19:01:13 · 111 阅读 · 1 评论 -
7081 二叉排序树的创建,查找,删除
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct bstnode{int data;struct bstnode *lchild,*rchild;}bstnode,*bstree;int searchbst(bstree mytree,int key){ if(mytree==NULL) return 0; if(key==mytree->da原创 2020-12-24 18:59:51 · 83 阅读 · 1 评论 -
7050 外拉链法解决散列冲突建立散列表
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}no;int main(){ no n[100]; int key,h; for(int i=0;i<13;i++) n[i].next=NULL;cin>>key;while(key){h=k原创 2020-12-15 16:53:40 · 152 阅读 · 0 评论 -
7051 线性探测法解决散列冲突
#include <iostream>#include<bits/stdc++.h>using namespace std;int main(){ int m,p,j,h,d=1; cin>>m; int data[100]={0}; for(int i=m;i>0;i--){ for(j=2;j<i;j++){ if(i%j==0)break; } if原创 2020-12-15 16:51:43 · 249 阅读 · 0 评论 -
7083 有序表折半查找算法
#include <iostream>#include<bits/stdc++.h>using namespace std;void search(int data[],int x,int len){int low,high,mid,num=0,pos=-1;low=1;high=len;mid=(low+high)/2;while(low<=high){if(data[mid]==x) {pos=mid;num++;break;}if(data[mid]&g原创 2020-12-15 16:50:20 · 397 阅读 · 0 评论 -
7041 以邻接表为基础的拓朴排序
#include <iostream>#include <bits/stdc++.h>using namespace std;typedef struct arc{int adjvex;struct arc *next;}arcnode;typedef struct vexnode{int data;int vnum;struct arc *first;}G;int visit[100];int result[100];G* creatg(){int原创 2020-12-07 20:21:54 · 96 阅读 · 0 评论 -
7042 邻接表存储实现无向图的深度优先非递归遍历
#include <iostream>#include <bits/stdc++.h>using namespace std;typedef struct arc{int adjvex;struct arc *next;}arcnode;typedef struct vexnode{int data;int vnum;struct arc *first;}G;int visit[100];G* creatg(){int m,n,x,y;arcnode *原创 2020-12-02 20:46:12 · 374 阅读 · 0 评论 -
7040 有向图邻接表存贮,计算入度,出度,度
#include <iostream>#include <bits/stdc++.h>using namespace std;typedef struct arc{int adjvex;struct arc *next;}arcnode;typedef struct vexnode{int data;int vnum;struct arc *first;}G;int visit[100];int result[100][4];G* creatg(){in原创 2020-12-02 20:44:18 · 387 阅读 · 0 评论 -
7039 邻接表 遍历邻接表 深度优先遍历 递归
#include <iostream>#include <bits/stdc++.h>using namespace std;typedef struct arc{int adjvex;struct arc *next;}arcnode;typedef struct vexnode{int data;int vnum;struct arc *first;}G;int visit[100];G* creatg(){int m,n,x,y;arcnode *原创 2020-12-02 20:42:52 · 166 阅读 · 0 评论 -
7043 利用邻接表实现无向图的广度优先遍历
#include <iostream>#include <bits/stdc++.h>using namespace std;typedef struct arc{int adjvex;struct arc *next;}arcnode;typedef struct vexnode{int data;int vnum;struct arc *first;}G;int visit[100];G* creatg(){int m,n,x,y;arcnode *原创 2020-12-02 20:41:10 · 315 阅读 · 0 评论 -
森林用孩子兄弟表示法,求森林叶子节点数 7080
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{char data;struct node *lchild,*rchild;}treeno,*treenode;void cre(treenode &root){char x;cin>>x;if(x=='@') root=NULL;else{ root=new treeno..原创 2020-11-10 21:06:47 · 651 阅读 · 0 评论 -
建立一颗二叉树,并求它的高度 7074
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{char data;struct node *lchild,*rchild;}treeno,*treenode;void cre(treenode &root){char x;cin>>x;if(x=='@') root=NULL;else{ root=new treeno..原创 2020-11-10 20:36:59 · 689 阅读 · 0 评论 -
先序建立一颗二叉树,并且后序遍历它 7075
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{char data;struct node *lchild,*rchild;}treeno,*treenode;void cre(treenode &root){char x;cin>>x;if(x=='@') root=NULL;else{ root=new treeno..原创 2020-11-10 20:35:58 · 14649 阅读 · 0 评论 -
建立二叉树,并求叶子节点数 7076
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{char data;struct node *lchild,*rchild;}treeno,*treenode;void cre(treenode &root){char x;cin>>x;if(x=='@') root=NULL;else{ root=new treeno..原创 2020-11-10 20:34:48 · 161 阅读 · 0 评论 -
建立一颗二叉树,用队列层序遍历它 7077
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{char data;struct node *lchild,*rchild;}treeno,*treenode;void cre(treenode &root){char x;cin>>x;if(x=='@') root=NULL;else{ root=new treeno..原创 2020-11-10 20:33:41 · 177 阅读 · 0 评论 -
先序建立一颗二叉树,并且中序线索化,然后中序线索遍历它 7078
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{char data;int ltag,rtag;struct node *lchild,*rchild;}treeno,*treenode;treenode p;void cre(treenode &root){char x;cin>>x;if(x=='@') root=NU原创 2020-11-10 20:32:48 · 346 阅读 · 0 评论 -
先序建立一颗二叉树并且非递归中序遍历它 7079
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{char data;struct node *lchild,*rchild;}treeno,*treenode;void cre(treenode &root){char x;cin>>x;if(x=='@') root=NULL;else{ root=new treeno..原创 2020-11-10 20:31:07 · 86 阅读 · 0 评论 -
循环队列基本操作 8565
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct{int *data;int front,rear;}myque;void init(myque &m){m.data=new int[100];m.front=m.rear=0;}void enque(myque &m,int x){if((m.rear+1)%100==m.front) ex原创 2020-11-03 21:31:57 · 82 阅读 · 0 评论 -
链队基本操作 8564
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}myqueuenode;typedef struct{myqueuenode *front,*rear;}myqueue;void init(myqueue &m){m.front=m.rear=new myqueuenode;m.fr原创 2020-11-03 21:31:25 · 72 阅读 · 0 评论 -
8569
#include <iostream>#include<bits/stdc++.h>#define max 100using namespace std;typedef struct{char *top;char *base;int size;} node;int input(char ch);char operate(char a,char fu,char b);char precede(char ch1,char ch2);char gettop(nod原创 2020-11-03 21:30:38 · 656 阅读 · 0 评论 -
栈实现进制相互转化 8566
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct{int *base;int *top;}mystack;void init(mystack &m){m.base=new int[100];m.top=m.base;}void push(mystack &m,int x){if(m.top==m.base+100) exit(0);*m.t原创 2020-11-03 21:29:04 · 78 阅读 · 0 评论 -
链栈的基本操作8562
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}Snode;void init(Snode* &s){s=new Snode;s=NULL;}void push(Snode* &s,int x){Snode *p=new Snode;p->data=x;p->原创 2020-11-03 21:27:49 · 64 阅读 · 0 评论 -
顺序栈的基本操作 8563
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct {int *base;int *top;}mystack;void init(mystack &m){m.base=new int[100];m.top=m.base;}void push(mystack &m,int x){if(m.top==m.base+100) exit(0);*m原创 2020-11-03 21:27:13 · 118 阅读 · 0 评论 -
用队列打印杨辉三角
#include <iostream>#include<bits/stdc++.h>#define maxsize 100using namespace std;typedef struct{int *data;int front;int rear;}myqueue;void init(myqueue &m){m.data=new int[maxsize];m.front=m.rear=0;}void enqueue(myqueue &m,原创 2020-10-31 20:45:28 · 184 阅读 · 0 评论 -
链表逆置 8554
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}no;int main(){ int n; no *p,*tail,*q; no *head=new no; head->next=NULL; tail=head; cin>>n; ...原创 2020-10-26 21:26:38 · 101 阅读 · 0 评论 -
建立单向链表并遍历 题号8553
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}no;int main(){ int n; no *p,*tail; no *head=new no; head->next=NULL; tail=head; cin>>n; w...原创 2020-10-26 21:25:47 · 83 阅读 · 0 评论 -
线性表逆置 题号8559
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct{int *data;}node;int main(){ int n,t; cin>>n; node a; a.data=new int[n]; for(int i=0;i<n;i++) { cin>>a.data[i]; ...原创 2020-10-26 21:24:53 · 118 阅读 · 0 评论 -
单向链表中删除偶数结点
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}no;no *cre(){no *head,*p,*tail;int n;head=new no;cin>>n;tail=head;while(n!=0){p=new no;p->data=n;p->n...原创 2020-10-17 14:56:28 · 496 阅读 · 0 评论 -
建立有序链表 8555
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}no;void youxu(no *head,no *p){no *q,*tail;q=head;tail=q->next;while(tail!=NULL&&tail->data<p->data){原创 2020-10-14 20:09:53 · 99 阅读 · 0 评论 -
建立两个非递减链表,合并成一个递增链表
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct node{int data;struct node *next;}no;void youxu(no *head,no *p){no *q,*tail;q=head;tail=q->next;while(tail!=NULL&&tail->data<p->data..原创 2020-10-14 20:08:09 · 342 阅读 · 0 评论 -
分解一个链表
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct note{struct note *next;int data;}No;No *cre(){int n;No *head,*p,*tail;head=new No;head->next=NULL;tail=head;cin>>n;while(n!=0){ p=new ...原创 2020-10-14 20:06:30 · 85 阅读 · 0 评论 -
单链表实现多项式相加
#include <iostream>#include<bits/stdc++.h>using namespace std;typedef struct note{struct note *next;int xishu;int zhishu;}No;No *cre(){int n,a,b;No *head,*p,*tail;head=new No;head->next=NULL;tail=head;cin>>...原创 2020-10-14 20:05:12 · 117 阅读 · 0 评论