![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Never KnowsTomorrowT
这个作者很懒,什么都没留下…
展开
-
数据结构--排序
1.冒泡排序(1)第一次比较:首先比较第一和第二个数,将小数放在前面,将大数放在后面。然后比较第2和第3个数,将小数放在前面,大数放在后面 ······ 。(2)在上面一趟比较完成后,最后一个数一定是数组中最大的一个数,所以在比较第二趟的时候,最后一个数是不参加比较的。······//简单冒泡排序举例【升序】# include <stdio.h>void bubble_sort(int *,int);int main(void){ int i; int le原创 2021-01-24 23:47:39 · 178 阅读 · 0 评论 -
数据结构--二叉树
#include<stdio.h>#include<malloc.h>struct BTNode{ int data;//数据域 struct BTNode *pLchhid;//左子树指针域,L是左,child是孩子,左子树 struct BTNode *pRchhid;//右子树指针域,R是右,child是孩子,右子树 };void PreTraverseBTree(struct BTNode * pT);//先序遍历二叉树void I原创 2021-01-24 21:56:58 · 80 阅读 · 0 评论 -
数据结构--汉诺塔
放弃你对于理解和跟踪递归全程的企图,站在高楼上看全貌# include <stdio.h>void hannuota(int n, char A, char B, char C)//把A上编号n的盘子借助B移到C{/* 如果是1个盘子 直接将A柱子上的盘子从A移到C 否则 先将A柱子上的n-1个盘子借助C移到B 直接将A柱子上的盘子从A移到C 最后将B柱子上的n-1个盘子借助A移到C*/ if (1 == n) { printf("--将编号为%d的盘子原创 2021-01-24 12:14:39 · 118 阅读 · 0 评论 -
数据结构--循环队列(数组实现)
#include <stdio.h>#include <malloc.h>typedef struct Queue{ int * pBase; int front; int rear;}QUEUE;void init(QUEUE *);bool en_queue(QUEUE *, int val); //入队void traverse_queue(QUEUE *);bool full_queue(QUEUE *);bool out_queue(QUEUE原创 2021-01-22 17:09:02 · 60 阅读 · 0 评论 -
数据结构--链式队列
# include <iostream>using namespace std;typedef struct node{ int data; struct node *pNext;}NODE, *PNODE;class Queue{private: PNODE pHead, pTail; //pHead指向无用的头结点 pHead->pNext才是指向队首元素, pTail指向队尾元素public: Queue(/* args */) { this-&g.原创 2021-01-21 11:55:57 · 108 阅读 · 0 评论 -
数据结构--对栈的操作
# include <stdio.h># include <stdlib.h># include <malloc.h>typedef struct Node{ int data; struct Node * pNext;}NODE,* PNODE;typedef struct Stack{ PNODE pTop; //指向栈第一个元素,存放栈元素地址,所以数据类型是struct Node类型 PNODE pBottom;}STACK原创 2021-01-20 18:00:43 · 125 阅读 · 0 评论 -
数据结构对数组的操作
//数据结构 对数组的操作2021/1/12/18点25分# include <malloc.h> //包含了malloc函数# include <stdio.h># include <stdlib.h> //包含了exit函数struct Arr{ int * pBase;/* data */ int len; int cnt;};void init_arr(struct Arr * pArr, int length); /原创 2021-01-19 17:15:18 · 127 阅读 · 0 评论 -
数据结构对链表的操作
#include <stdio.h>#include <malloc.h>#include <stdlib.h>typedef struct Node{ int data; struct Node * pNext;//指针域}NODE, *PNODE;//NODE等价于struct Node PNODE等价于struct Node *//函数声明PNODE create_list(void); //创建链表void traverse_lis原创 2021-01-19 17:13:09 · 66 阅读 · 0 评论