
数据结构(C语言版)
Long_UP
随便写的,水平一般,都是学校学的知识,怕忘记写的,我自己能看的懂就行,有些太久用不到,该忘的都忘了。侵权请联系删除。
展开
-
C语言—串复杂操作
#include <stdio.h>#include <stdlib.h>#define MAX_NUM 100typedef struct str{ char ch[MAX_NUM+1]; int length;}*SString;SString initSString() //字符串初始化{ SString str=(SString)malloc(sizeof(struct str)); if(!str) {原创 2021-12-15 14:08:27 · 330 阅读 · 0 评论 -
C语言—串
#include <stdio.h>#include <stdlib.h>#define MAX_NUM 100typedef struct str{ char ch[MAX_NUM+1]; int length;}*SString;SString initSString() //字符串初始化{ SString str=(SString)malloc(sizeof(struct str)); if(!str) {原创 2021-12-15 14:07:34 · 1263 阅读 · 0 评论 -
C语言—循环队列
#include <stdio.h>#include <stdlib.h>#define MAXQSIZE 100 //队列最大长度typedef int QElemType;typedef struct { QElemType *base; //初始化动态分配存储空间 int front; //头指针,队列为不空,指向队列头元素 int rese; //尾指针,队列不为空,指向尾元素的下一个位置 }SqQueue;void InitQueu(SqQ原创 2021-12-07 13:31:08 · 483 阅读 · 0 评论 -
C语言—链队列
#include <stdio.h>#include <stdlib.h>typedef int QElemType;typedef struct Qnode { QElemType data; //数据域 struct Qnode *next; //队列指针域}QNode, *QueuePtr;typedef struct { QueuePtr front; //队列头指针 QueuePtr rear; //队列尾指针}LinkQueue;vo原创 2021-12-07 13:30:11 · 396 阅读 · 0 评论 -
C语言—数制转换
#include <stdio.h>#include <stdlib.h>#include <math.h>#define STACK_INIT_SIZE 100 //存储空间初始分配量#define STACKINITCREMENT 10 //存储空间分配增量typedef int SElemType;typedef struct { SElemType *base; //栈底指针-空栈时为 NULL SElemType *top; //栈顶指原创 2021-12-07 13:28:57 · 1971 阅读 · 0 评论 -
C语言—栈
#include <stdio.h>#include <stdlib.h>#define STACK_INIT_SIZE 100 //存储空间初始分配量#define STACKINITCREMENT 10 //存储空间分配增量typedef int SElemType;typedef struct { SElemType *base; //栈底指针-空栈时为 NULL SElemType *top; //栈顶指针 int stacksize; //当前原创 2021-12-07 13:28:08 · 458 阅读 · 0 评论 -
C语言—双向链表
#include <stdio.h>#include <stdlib.h>typedef int ElemType;typedef struct dlnode{ ElemType data; struct dlnode *prior,*next;}DLNode,*DLinkList;void CreateDLinkList(DLinkList &DL) //创建双向链表{ int i,num; DLinkList p,s; DL = (DLNode *原创 2021-12-07 13:26:11 · 778 阅读 · 0 评论 -
C语言—循环单链表
#include<stdio.h>#include<stdlib.h>typedef int ElemType;typedef struct lnode{ ElemType data; struct lnode *next;}LNode,*LinkList;int CreateLinkList(LinkList &L,int num) //创建循环单链表{ int i; LinkList s,p; p = L = (LNode *)malloc(si原创 2021-12-07 13:24:25 · 975 阅读 · 0 评论 -
C语言—单链表
#include<stdio.h>#include<stdlib.h>#include<malloc.h>typedef struct LNode{ int data; struct LNode *next;}LNode,*LinkList;LinkList CreateList(int n) //构建单链表 { LinkList L,p,q; int i; L=(LNode*)malloc(size原创 2021-12-07 13:23:03 · 263 阅读 · 0 评论 -
C语言—顺序表
#include <stdio.h>#include <stdlib.h> //进程头文件#define LIST_INIT_SIZE 100 //预设空间容量#define LISTINCREAMENT 10 //扩展空间增量typedef int ElemType; //数据元素类型typedef struct{ ElemType *elem; //基地址 int length; //当前长度 int listsize; //当前空间容量(单位为个.原创 2021-12-07 13:21:49 · 459 阅读 · 0 评论 -
C语言—顺序表排序递增及归并
#include <stdio.h>#include <stdlib.h>#define LIST_INIT_SIZE 50typedef int ElemType;typedef struct{ ElemType *elem; int length; int listsize;}SqList;void CreateList(SqList &L) //创建顺序表{ int num,i; scanf("%d",&num); L.elem原创 2021-12-07 13:19:46 · 1555 阅读 · 0 评论 -
C语言—数据集合
#include <stdio.h>/*数组A={9,-2,4,-1,6,7,-3},调整后即为:{-2,-1,-3,9,4,6,7}*/int main(){ int a[7]={9,-2,4,-1,6,7,-3}; int *p,*q; int temp; p = &a[0]; q = a + 6; printf("\n未调整的数据集合\n"); while(p <= a + 6) { printf("%4d",*p); p++; }原创 2021-12-07 13:16:01 · 473 阅读 · 0 评论