b zhan 郝斌数据结构
墨启飞
一位计算机科学与计算专业的大一学生,热爱编程,发布的博客有不足的地方,欢迎前辈进行指导,感激不尽。
展开
-
树的静态创建
#include<stdio.h>#include<malloc.h>struct Tree { char data; struct Tree*Lchildren; struct Tree*Rchildren;};struct Tree* creationtree(void) { struct Tree* pA = (struct Tree*)malloc(sizeof(struct Tree)); struct Tree* pB= (struct Tree*)m.原创 2021-12-14 16:48:38 · 277 阅读 · 0 评论 -
汉诺塔———递归问题
#define _CRT_SECURE_NO_WARNINGS# include <stdio.h>void hannuota(int n, char A, char B, char C){ /* 如果是1个盘子 直接将A柱子上的盘子从A移到C 否则 先将A柱子上的n-1个盘子借助C移到B 直接将A柱子上的盘子从A移到C 最后将B柱子上的n-1个盘子借助A移到C */ if (1 == n) { printf("将编号为%d的盘子直接从%c柱.原创 2021-12-08 21:02:36 · 135 阅读 · 0 评论 -
双向静态队列的创建
#include<stdio.h>#include<malloc.h>struct Queue { int* pdata; int front; int later;};void init_Queue(struct Queue*ps) { ps-> pdata = (int*)malloc(sizeof(int) * 8); //bug:int* pdata = (int*)malloc(sizeof(int) * 8); 这样写的话就不是队列分配内存空.原创 2021-12-07 20:18:12 · 402 阅读 · 0 评论 -
栈的创建——
#include<stdio.h>#include<stdlib.h>#include<malloc.h>struct Node { int data; struct Node* pNext;};struct stack { struct Node*pTop; struct Node* pBottom;};bool init_stack(struct stack*ps) { ps->pTop = (struct Node*)malloc.原创 2021-12-07 10:22:32 · 577 阅读 · 0 评论 -
链表的建立
//代码1# include <stdio.h># include <malloc.h># include <stdlib.h>typedef struct Node //声明所有类型为struct Node的节点{ int data; //数据域 struct Node * pNext; //指针域}NODE, *PNODE; //NODE等价于struct Node PNODE等价于struct Node *//函数声明PNODE cr.原创 2021-12-05 01:01:00 · 383 阅读 · 0 评论 -
p12-连续存储数组的算法演示
#include<stdio.h>#include<malloc.h>#include<stdlib.h>//包含了exit //定义了一个数据类型,该数据类型的名字叫做struct Array, 该数据类型含有三个成员,分别是lenght, data, sizestruct Array { int lenght;////数组所能容纳的最大元素的个数 int* data;//分配到的动态数组首元素的地址 int size;//当前数组有效元素的个数};.原创 2021-11-30 12:33:52 · 691 阅读 · 0 评论