分类: 数据结构

4 篇文章

数据结构 栈代码
顺序栈(数组实现) #include <stdio.h> // 元素 elem 进栈,a 为数组,top 值为当前栈的栈顶位置 int push (int* a,int top,int elem) { a [++top]=elem; return top; } // 数据元素出栈 int pop (int * a,int top) { if (top=…
数据结构 顺序表代码
#include <stdio.h> #include <stdlib.h> //malloc ()、exit () #define Size 5 // 对 Size 进行宏定义,表示顺序表申请空间的大小 typedef struct Table { int * head; // 声明了一个名为 head 的长度不确定的数组,也叫 “动态数组” int …
数据结构 链表代码
简单链表 #include <stdio.h> struct student { long num; float score; struct student *next; }; void main () { struct student a, b, c, *head, *p; a.num = 99101; a.score = 89.5; …
C 数据结构代码(持续更新中)
// 数组栈的实现 #include<stdio.h> #define MaxSize 50 typedef struct Stack_Array { int data [MaxSize]; int top; } Sqstack,*pSqstack; void Initstack (); // 初始化 int Isempty (); // 判断栈空 …