- 博客(27)
- 收藏
- 关注
转载 线性表操作(三)
两个等长的升序数组中,找出两个序列的中位数思想:若a为A的中位数,b为B的中位数,若a=b,则就为两个数组的中位数,若a<b,则A舍弃左边,B舍弃右边,两边舍弃等长的部分,然后重新比较两个剩下部分的中位数,以此类推。若a>b,则相反。void SearchM(SqList &L1,SqList &L2){ int h1,h2,r1,r...
2019-09-28 21:36:00
240
转载 线性表操作(二)
删除单链表中最小值节点void Deletemin(LinkList &L){ LinkList p,q; LinkList minpre,pre; pre=L;//最小值节点的前驱 q=pre->next; minpre=pre; p=q; int temp=q->data; w...
2019-09-26 21:48:00
172
转载 排序应用(一)
时间最少,辅助空间最少,把所有奇数移动到偶数前边思想:从顺序表的两边同时遍历进行奇偶交换void move1(){ int A[6]={4,5,1,2,6,3}; int temp; int i=0,j=5; while(i<j){ while(A[i]%2==1){i++;} while(A[...
2019-09-18 22:12:00
276
转载 排序
插入排序:直接插入排序,折半插入排序,希尔排序交换排序:冒泡排序,快速排序选择排序:简单选择排序,堆排序归并排序基数排序#include <stdio.h>#include <stdlib.h>void InsertSort(int A[],int n){ int B[7]; int i,j; for(...
2019-09-18 20:34:00
133
转载 串的模式匹配
串的模式匹配一般分为两种:简单模式匹配和KMP算法#include <stdio.h>#include <stdlib.h>#define MaxSize 100typedef struct{ char str[MaxSize+1]; int length;}Str;//串的存储结构int index1(Str *s...
2019-09-16 21:38:00
367
转载 顺序查找和折半查找
顺序查找可以是线性表也可以是链表,同是既可以是有序的也可以是无序。折半查找仅适用于有序的线性表#include <stdio.h>#include <stdlib.h>#define ElemType inttypedef struct{ ElemType *elem; int TableLen;}SSTable;/...
2019-08-29 22:10:00
281
转载 弗洛伊德求每个顶点到其余各顶点的最短路径
以5 a b 7 a d 4 b c 2 b d 3 c a 3 c b 2 c d 1 d c构造有向图并找出每个顶点到其余顶点的最短路径#include <stdio.h>#include <stdlib.h>#define MaxVertexNum 100#define BIG 100typedef char VertexType;/...
2019-08-27 23:05:00
340
转载 迪杰斯特拉最短路径
以4 a b 1 b c 6 a c 6 a d 2 d c 7 b e 6 c e 4 c f 5 d f 1 f e 6 e g 8 f g构造有向图并找出最短路径#include <stdio.h>#include <stdlib.h>#define MaxVertexNum 100#define BIG 100typedef cha...
2019-08-27 21:33:00
171
转载 最小生成树
Prim和Kruskal都是针对无向图而言的以5 a b 1 a c 2 a d 3 b c 6 c d 4 b e 3 d e 2 c e生成有权无向图,并生成最小生成树#include <stdio.h>#include <stdlib.h>#define MaxVertexNum 100#define BIG 100typedef...
2019-08-25 20:31:00
102
转载 广度优先搜索与深度优先搜索
广度优先搜索typedef struct { int que[MaxVertexNum]; int rear,front;}Queue;//广度优先搜索队列的存储结构int visit[MaxVertexNum];//全局变量数组void BFS(MGraph &M,int v){ printf("广度优先搜索:"); ...
2019-08-18 21:25:00
122
转载 图实现
构造一个有向图边关系:5 a b7 a d 4 b c 8 c a 9 c f 5 d c 6 d f 5 e d 1 f e 3 f a#include <stdio.h>#include <stdlib.h>#define MaxVertexNum 100typedef char VertexType;//顶点节点的数据类型typ...
2019-08-17 22:15:00
201
转载 编程中出现的问题
一. 第一个scanf()函数可以正常使用,后续的scanf()函数无法再次输入可能原因:缓存被占据使用fflush(stdin)清除缓存二.在连续输入字符时注意使用getchar()清除空格转载于:https://www.cnblogs.com/Yshun/p/11370199.html...
2019-08-17 20:22:00
267
转载 生成哈夫曼树
给定权集{5,7,2,3,6,8,9}构造哈夫曼树#include <stdio.h>#include <stdlib.h>#define ElemType int#define MAXSIZE 20#define length 7typedef struct HFNode{ ElemType weight; str...
2019-08-12 21:15:00
469
转载 二叉排序树操作(一)
判断给定的二叉树是否是二叉排序树void JudegBST(BSTree &T){ Queue q; BSTree bst; int flag=1; q.front=-1; q.rear=-1; q.a[++q.rear]=T; while(q.front<q.rear){ ...
2019-08-09 20:42:00
134
转载 二叉排序树实现
由{4,9,0,1,8,6,3,5,2,7}创建一个二叉排序树#include <stdio.h>#include <stdlib.h>#define MAXSIZE 20#define ElemType inttypedef struct BSTNode{ ElemType data; struct BSTNod...
2019-08-07 21:37:00
190
转载 树与二叉树操作(一)
非递归求二叉树的高度void BiDepth(BiTree &T){ BiTree bit; int last=0,level=0; Queue q; q.rear=-1; q.front=-1; if(!T){ return ; } q.rear++; q.b[q...
2019-08-03 21:09:00
137
转载 数据结构 树(一)
m叉树从根节点用1开始编号,则第i个节点的第1个孩子节点的编号jj=(i-1)*m+2https://wenku.baidu.com/view/079df02bdcccda38376baf1ffc4ffe473268fd5b转载于:https://www.cnblogs.com/Yshun/p/11279507.html...
2019-07-31 22:16:00
390
转载 二叉树实现
二叉链表(C++)采用先序序列建立二叉链表,字符串:A B C # # D E # G # # F # # ##include <stdio.h>#include <stdlib.h>#define ElemType char#define MAXSIZE 20typedef struct BiTNode{ ElemType ...
2019-07-29 21:37:00
135
转载 队列实现
链队列#include <stdio.h>#include <stdlib.h>#define ElemType inttypedef struct QNode{ ElemType data; struct QNode *next;}QNode,*QueuePtr;//结点结构体typedef struct{ QueuePtr fron...
2019-07-11 20:22:00
155
转载 栈、队列操作(一)
给定入栈出栈顺序判断是否合法,顺序以一维数组给定int gudge(SqStack *s,ElemType a[8]){ int e; int empty; for(ElemType i=0;i<8;i++){ printf("%d\n",a[i]); empty=StackEmpty1(s); if(a[i]=...
2019-07-10 21:39:00
196
转载 栈实现
顺序栈#include <stdio.h>#include <stdlib.h>#define Maxsize 10#define ElemType inttypedef struct { ElemType *top; ElemType *base; int stacksize;//栈的大小}SqStack;int InitStack(SqS...
2019-07-09 21:32:00
259
转载 单链表操作(一)
将一个带有头结点的单链表反向输出思想:每当访问一个结点时,先递归输出它后面的结点void ReverseList(LinkList &L){ if(L->next!=NULL){ ReverseList(L->next); } printf("%d ",L->data);}函数调用为:ReverseList(L->...
2019-07-05 22:20:00
141
转载 实现单链表
因为在传递函数参数时,使用了引用,所以该程序为C++程序#include <stdio.h>#include <stdlib.h>#define ElemType inttypedef struct LNode{ ElemType data; struct LNode *next; int length;}LNode, *LinkList;i...
2019-07-05 21:44:00
157
转载 线性表和数组操作(一)
在一个一维数组中将所有的元素循环左移p(0<p<n)个位置思想:ab=>ba,aˉ1bˉ1=(ba)ˉ1#include <stdio.h>void Reverse(int a,int b,int R[10]){ for(int i=0;i<(b-a+1)/2;i++){ int temp; temp=R[a+...
2019-07-03 20:19:00
117
转载 GUI学习(二):输入三角形三边计算出三角形的面积
JTextField的内容为字符串型想要转换成double型只能在actionPerformed()中转换,只有这样才不会出错package Work;import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public ...
2019-07-02 21:50:00
887
转载 数组字符串和枚举
与C/C++不同,Java中不允许在声明数组时指定数组的元素个数 如:int a[12] 错误,int a[]=new int[12]正确转载于:https://www.cnblogs.com/Yshun/p/11123371.html
2019-07-02 21:46:00
207
转载 实现顺序表
#include <stdio.h>#include <stdlib.h>#define ElemType int#define MaxSize 10 //顺序表最大长度#define InitSize 5 //顺序表初始的长度typedef struct{ElemType *data;int length;}SqList;int InitList(SqList ...
2019-07-02 21:44:00
139
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅