自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 收藏
  • 关注

原创 线索二叉树

#include <stdio.h> #include <stdlib.h> typedef char ElemType; typedef enum{Link,Thread} PointerTag; typedef struct BiThrNode{ ElemType data; PointerTag ltag,rtag; struct BiThrNode *lchild,*rchild; }BiThrNode,*BiThrTree; BiThrTree

2021-08-28 17:55:16 139

原创 二叉树建立和遍历

#include <stdio.h> #include <stdlib.h> //结构 typedef struct BiTNode{ char data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; //创建二叉树 void CreateBiTree(BiTree *T){ char c; scanf("%c",&c); if(c==' '){ *T=NULL;

2021-08-25 09:20:23 126

原创 汉诺塔问题

汉诺塔通过递归方法实现,可以将n个盘子依次的变成n-1个盘子,每次调用函数时,就是将盘子插在x,y,z不同位置上,通过对x,y,z位置进行改变解决问题。 假设盘子最初都插在x上,主要是三个步骤: 将n-1个盘子借助z移到y上 将x上的最后一个盘子移到z上 将y上的盘子借助x移到z上 void move(int n,char x,char y,char z){ if(n==1){ printf("%c-->%c\n",x,z); } else{

2021-08-24 11:53:16 153

原创 KMP算法

KMP算法主要是对两个字符串匹配问题发明的算法,是D.E.Knuth、J.H.Morris和V.R.Pratt三位前辈的研究结果。 代码如下: #include <stdio.h> #include <stdlib.h> 1.获取next数组: typedef char* String; void get_next(String T,int next[10]){ int j=0,i=1; next[1]=0; while(i<T[0]){

2021-08-24 11:39:13 112

原创 链式队列结构及实现

#include <stdio.h> #include <stdlib.h> #define error 0 #define ok 1 1.结构 typedef struct QNode { int data; struct QNode *next; }QNode,*QueuePrt; typedef struct{ QueuePrt front,rear; }LinkQueue; 2.初始化 int initQueue(LinkQueue *q){

2021-08-21 18:38:09 111

原创 队列的结构及实现

#include <stdio.h> #include <stdlib.h> #define error 0 #define ok 1 #define MAXSIZE 10 1.结构 typedef struct cycleQueue { int *base; int front; int rear; }cycleQueue; 2.初始化 int initQueue(cycleQueue *q){ q->base=(int *)malloc(

2021-08-21 18:28:13 102

原创 折半查找法

使用递归实现折半查找,主函数可以根据自己的需要进行修改,这里只是为了调试方便。med()函数返回值是要查找的数值在数组中的位置。 #include <stdio.h> #include <stdlib.h> int med(int low,int high,int n,int a[5]){ int mid=(low+high)/2; if(low>=high){ return 0; } else if(a[mid]>n){

2021-08-21 18:21:33 160

原创 二进制转十进制-栈

#include <stdio.h> #include <stdlib.h> #include <math.h> #define error 0 #define ok 1 #define MAXSIZE 10 #define STACKINCREMENT 10 1.结构 typedef struct sqStack { int *base; int *top; int stackSize; }sqStack; 2.初始化 int initSta

2021-08-21 08:51:11 147

原创 循环链表-约瑟夫

#include <stdio.h> #include <stdlib.h> #define error 0 #define ok 1 1.结构(循环链表) typedef struct Node { int data; struct Node *next; }Node,*LNode; 2.初始化 int InitList(LNode *L){ int item=1; LNode p,target; *L=(LNode)malloc(siz

2021-08-21 08:44:00 138

原创 单链表求中间节点

#include <stdio.h> #include <stdlib.h> #include <time.h> #define error 0 #define ok 1 1.结构 typedef struct Node { int data; struct Node *next; }Node; typedef struct Node* LinkList; 2.创建链表 int CreateListHead(LinkList *L,int n){

2021-08-19 19:41:36 187

原创 单链表的实现

#include <stdio.h> #include <stdlib.h> #include <time.h> #define error 0 #define ok 1 1.结构 typedef struct Node { int data; struct Node *next; }Node; typedef struct Node* LinkList; 2.初始化 //头插法创建n个元素的链表 int CreateListHead(LinkList

2021-08-19 10:31:09 92

原创 静态链表的实现

#include <stdio.h> #include <stdlib.h> #define MAXSIZE 10 #define error 0 #define ok 1 1.例子 // 游标 5 2 3 4 0 6 7 ... 1 // 数据 A C D E ... // 下标 0 1 2 3 4 5 6 ... 9 2.结构 typedef struct{

2021-08-19 10:24:00 93

原创 线性表

线性表 本篇文章是对线性表创建以及插入、删除元素等功能的编写。 #include <stdio.h> #include <stdlib.h> #define MAXSIZE 10 //容纳的元素个数 #define false 0 #define true 1 #define error 0 #define ok 1 1.定义表的结构 typedef struct { /* data */ int *elem; int listSize; int l

2021-08-18 10:42:31 143

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除