一些关于链表操作的代码
摘要:#include #include #include #define SIZE 10 struct node { int num; struct node *next; }; struct stud { char name[10]; int num; }sw[5],sr[5],*pw,*pr; void selectsort(int *); void b...
阅读全文
posted @
2017-03-18 00:31
lie隼
阅读(161)
推荐(0) 编辑
简单二叉树的建立和遍历
摘要:#include#include//定义节点typedef struct BiNode{ char data; struct BiNode *lch; struct BiNode *rch;}BiNode,*BiTree;//先序建立二叉树void Crea...
阅读全文
posted @
2017-03-13 13:47
lie隼
阅读(294)
推荐(0) 编辑
约瑟夫环问题之选猴王
摘要:n只猴子围成一圈,顺时针方向从1到n编号。之后从1号开始沿着顺时针方向让猴子从1,2,3……,m依次报数,凡报到m的猴子都让其出圈,取消候选资格。然后不停的俺顺时针方向报数,让报到m的猴子出圈,最后剩下一个就是猴王。#include #include struct mon{ int num; ...
阅读全文
posted @
2015-10-28 21:38
lie隼
阅读(292)
推荐(0) 编辑
快速排序以及二分查找的实现
摘要:#include int BinSearch(int a[],int left,int right,int key);//声明二分查找void QuickSort(int a[],int left,int right);//声明快速排序int main(){ int a[101]; in...
阅读全文
posted @
2015-10-28 10:57
lie隼
阅读(161)
推荐(0) 编辑
顺序队列的基本操作
摘要:#include #include //#include #define MAXSIZE 100#define OK 1#define TRUE 1#define FALSE 0#define ERROR 0//using namespace std;typedef struct{ int d...
阅读全文
posted @
2014-02-11 21:56
lie隼
阅读(904)
推荐(0) 编辑
基于顺序栈的进制转换
摘要:#include #include #define M 10typedef struct //定义一个顺序栈{ int data[M]; int top;}SqStack;void InitStack(SqStack &st)//创建一个栈{ st.top=-1;}int Pu...
阅读全文
posted @
2013-10-09 09:36
lie隼
阅读(377)
推荐(0) 编辑
队列的链式存储及其基本运算
摘要:#include #include #define QueueSize 10typedef struct Qnode //链队列的定义{ char data; struct Qnode *next;}Qtype; //链队中节点类型typedef s...
阅读全文
posted @
2013-08-15 15:42
lie隼
阅读(363)
推荐(0) 编辑
队列的顺序存储及其基本操作
摘要:#include #include #define QueueSize 10typedef struct{ char data [QueueSize]; int front,rear;}SqQueue;void InitQueue(SqQueue &qu) //初始化队列{ qu...
阅读全文
posted @
2013-08-15 09:57
lie隼
阅读(387)
推荐(0) 编辑
栈的顺序存储及其基本操作
摘要:#include #include #define M 10typedef struct //定义一个顺序栈{ char data[M]; int top;}SqStack;void InitStack(SqStack &st)//创建一个栈{ st.top=-1;}int P...
阅读全文
posted @
2013-08-14 11:13
lie隼
阅读(345)
推荐(0) 编辑
栈的链式存储及其基本运算
摘要:#include #include #define M 10typedef struct stnode{ char data; struct stnode *next;}LinkStack;void InitStack(LinkStack *&ls) //初始化栈{ ls=NUL...
阅读全文
posted @
2013-08-14 10:56
lie隼
阅读(271)
推荐(0) 编辑
链表的逆置,归并,拆分以及其他函数集合
摘要:#include #include struct node{ int data; struct node *next;};struct node * creat1(int n)//逆序建立链表{ struct node *head,*p; int i; head=(st...
阅读全文
posted @
2013-08-10 11:07
lie隼
阅读(456)
推荐(0) 编辑