数据结构
Godfiry
这个作者很懒,什么都没留下…
展开
-
数据结构之冒泡排序
交换类排序法所谓交换排序法是指借助数据元素之间互相交换进行排序 的方法。冒泡排序与快速排序法都属于交换类排序方法。 交换排序— 冒泡排序:基本思想:比较相邻的元素。 如果第一个比第二个大,就交换他们两个。对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。 这步做完后,最后的元素会是最大的数。针对所有的元素重复以上的步骤,除了最后一个。持续每次对越来越少的元素重复上面的步骤,直到没有任何一对数字需要较。/* * @Author: Godfiry * @Date: 2原创 2021-03-24 16:59:59 · 189 阅读 · 0 评论 -
数据结构复习第三章:动态数组
#include<stdio.h>#include<stdlib.h>int main(){ int i,j,k; int n1,n2,n3; int ***arr = NULL; scanf("%d %d %d",&n1,&n2,&n3); arr = (int ***)calloc(n1,sizeof(int **)); for(i = 0;i < n1;i++) {原创 2020-07-03 21:42:40 · 118 阅读 · 0 评论 -
C语言复习第六章:双向链表
#include<stdio.h>#include<stdlib.h>typedef struct node{ int data; struct node *pre; struct node *next;}node;struct node tail_sentinel;struct node head_sentinel = {0, NULL, &tail_sentinel};//创建一个头结点struct node tail_sentinel = {0,原创 2020-07-03 20:57:26 · 123 阅读 · 0 评论 -
C语言复习第六章:循环链表
1.带有节点的循环链表与普通的带头结点链表相比,循环链表在做删除,销毁,遍历等操作时主要是看最后一个节点的指针域是否指向头结点;#include <stdio.h>#include <stdlib.h>typedef struct node{ int data; struct node *next;}node;node *head = NULL;static node head_sentinel={0,NULL};int init_link(){原创 2020-07-03 20:40:18 · 167 阅读 · 0 评论 -
数据结构复习第二章:队列
链表实现队列#include<stdio.h>#include<stdlib.h>typedef struct node{ int data; struct node *next;}node;node *head = NULL;node *mk_node(int data){ node *p = (node*)malloc(sizeof(node)); if(p == NULL) { printf("原创 2020-07-03 20:34:25 · 89 阅读 · 0 评论 -
数据结构复习第一章:栈
1.链表实现栈#include<stdio.h>#include<stdlib.h>typedef struct node{ int data; struct node *next;}node;node *head = NULL;node *mk_node(int data){ node *p = (node*)malloc(sizeof(node)); if(p == NULL) { printf("É原创 2020-07-02 21:17:24 · 96 阅读 · 0 评论