数据结构
_小页_
2020年毕业的打工人
展开
-
C语言实现链表从尾到头输出(采用递归思想)
比如:输入一个链表,按链表从尾到头的顺序返回一个ArrayList#include"stdio.h"#include"stdlib.h"typedef struct node * pointer;struct node{ char dat; pointer next;};pointer creat( pointer rear){ pointer p,head; cha...原创 2019-11-23 12:09:00 · 585 阅读 · 0 评论 -
数据结构:二分查找
#include"stdio.h"int find(int *r,int n,int key){ int low=1,high=n,mid; mid=(low+high)/2; while(low<high){ if(r[mid]==key) break ; if(r[mid]>key) high=mid-1; else { low=mid+1;...原创 2019-11-21 08:43:13 · 100 阅读 · 0 评论 -
数据结构:快速排序,代码可直接copy调试
数据结构中快速排序,代码直接copy调试#include"stdio.h"//单次排序int quick_s(int *r, int p, int q){ int i, j; i = p; j = q; r[0] = r[i]; while (i < j){ while (r[0] <= r[j]&&i<j) j--; if (i &l...原创 2019-11-05 22:09:59 · 106 阅读 · 0 评论 -
数据结构:插入排序,附有代码案例
插入排序思想:每次将无序区第1条记录插入到有序区适当位置。初始取第1条记录为有序区,其它记录为无序区。随着排序进行,有序区不断扩大,无序区不断缩小。最终无序区为空,有序区包含了全部记录,排序结束。以下代码案例,可copy调试#include"stdio.h"void insert_order(int *dat,int n){ int i,j; for(i=2;i<=n;i++)...原创 2019-11-05 15:10:20 · 204 阅读 · 0 评论 -
数据结构:链表二叉树的创建、前序遍历、中序遍历、后序遍历
数据结构链表二叉树的创建、前序遍历、中序遍历、后序遍历。代码可直接copy调用#include"stdio.h"#include"stdlib.h"typedef struct node * pointer;struct node{ char data; pointer lchild,rchild;};//创建树pointer creat(){ pointer t; ...原创 2019-11-05 10:53:45 · 717 阅读 · 0 评论 -
数据结构:队列链表,此代码有初始化、入队、出队、判断队是否为空
数据结构队列链表,此代码有初始化、入队、出队、判断队是否为空,可以直接copy调试。#include"stdio.h"#include"stdlib.h"typedef struct node * pointer;struct node{ int data; pointer next;};typedef struct { pointer front,rear;}queu...原创 2019-11-04 14:51:09 · 1079 阅读 · 0 评论 -
数据结构:队列的顺序存储代码,入队、出队、判断队空、初始化
队列的顺序存储代码,入队、出队、判断队空、初始化。可copy直接用#include"stdio.h"#define max 10typedef struct{ int data[max]; int front,rear;}queue;//初始化void init(queue *q){ q->front=q->rear=0;}//判断是否是空队int emp...原创 2019-11-04 09:53:37 · 1862 阅读 · 0 评论 -
数据结构:单链表创建增加节点、求表长、查找并定位链表节点数据、插入链表节点、删除链表节点,最后打印出来;可直接复制代码运行并检验
数据结构结构中单链表创建增加节点、求表长、查找并定位链表节点数据、插入链表节点、删除链表节点,最后打印出来;可直接复制代码运行并检验;注意:这里的代码编译环境是vs2013,如果你在其他的编译环境可以先把"scanf_s"改成"scanf"#include"stdio.h"#include"stdlib.h"typedef struct node * pointer;typedef ...原创 2019-11-03 16:18:00 · 280 阅读 · 0 评论 -
数据结构,线性表的顺序实现,有插入、删除、定位查找函数
以下线性表代码有插入、删除、定位查找功能,可以直接复制运行#include"stdio.h" #define max 10typedef struct{ int data1[max]; int n;}list;//删除void del(list *l,int i){ int j; if(l->n<=0) return; if(i&l...原创 2019-10-31 21:39:21 · 1013 阅读 · 0 评论