分类: 数据结构

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; …