上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 /*有序表查找-折半查找 9 折半查找有称为二分查找,线性表中的记录必须是关键码有序,通常是从小到大10 线性表必须采用顺序存储.11 基本思想:在有序表中,取中间记录作为比较对象,若给定值与中间记录的关键字相等,则查找成功;12 若给定值小于中间记录的关键字,则在中间记录的左半区继续查找;若给定值大于中间记录的关键字,13 则在中间记录的右半区继续查找。不断重复上述过程.直到找到成功,或所有查找区域无记录, 阅读全文
posted @ 2014-02-15 15:51 CrazyCode. 阅读(1024) 评论(0) 推荐(0) 编辑
摘要: a为数组,n为要查找的数组个数,key为要查找的关键字.顺序查找又称为线性查找:从表中第一个或者最后一个记录开始,逐个进行记录的关键字和给定值比较,若某个记录的关键字和给定值相等,则查找成功,找到所查记录;如果直到最后一个(或第一个)记录,其关键字和给定值比较都不等的时候.则表中没有所查的记录,查找不成功. 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 //顺序表查找的两种方法 9 int Sequential_Search(int *a,int n,i 阅读全文
posted @ 2014-02-15 15:29 CrazyCode. 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 typedef char VertexType;//顶点类型 8 typedef int EdgeType;//权值类型 9 const int maxVex = 100; 10 typedef struct EdgeNode//边表 11 { 12 int adjvex; 13 EdgeType weight; 14 struct EdgeNode *next; 15 }EdgeN... 阅读全文
posted @ 2014-02-12 19:50 CrazyCode. 阅读(2591) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 //邻接矩阵存储结构 7 typedef char VertexType; 8 typedef int EdgeType;//权值类型 9 const int maxVex = 100;//最大顶点数10 const int inFinity = 65535;//代表无穷大11 typedef struct 12 {13 VertexType vexs[maxVex];//顶点表14 EdgeType arc[ma. 阅读全文
posted @ 2014-02-12 11:21 CrazyCode. 阅读(1511) 评论(0) 推荐(0) 编辑
摘要: 其实建立的方式和遍历是一个意思.也是利用了递归的原理.只不过在原来应该是输出结点的地方,改成了生成结点,然后给这个结点进行赋值操作。所以理解了遍历就很容易理解建立. 1 #include "stdafx.h" 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 typedef char TElemType; 9 typedef int Status; 10 const int ok = 1; 11 const int error = 0; 12 typedef struct BiTNode 13 ... 阅读全文
posted @ 2014-02-11 14:41 CrazyCode. 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //循环队列的顺序存储结构 7 8 typedef int Status; 9 const int ok = 1;10 const int error = 0;11 const int maxSize = 5;12 13 typedef int QElemType;14 15 typedef struct QNode16 {17 QElemType data;18 struct QNode *next;19 }QNode,*Qu... 阅读全文
posted @ 2014-02-09 19:34 CrazyCode. 阅读(923) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //循环队列的顺序存储结构 7 typedef int QElemType; 8 typedef int Status; 9 const int ok = 1;10 const int error = 0;11 const int maxSize = 5;12 13 typedef struct 14 {15 QElemType data[maxSize];16 int front;17 int rear;18 }SqQu... 阅读全文
posted @ 2014-02-09 17:51 CrazyCode. 阅读(586) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //栈的链式存储结构及实现 7 //栈的结构定义 8 #define OK 1 9 #define ERROR 010 #define TRUE 111 #define FALSE 012 typedef int sElemType;13 typedef int Status;14 15 16 typedef struct StackNode17 {18 sElemType data;19 struct StackNode *ne.. 阅读全文
posted @ 2014-02-08 17:15 CrazyCode. 阅读(2635) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //栈的顺序存储结构及实现 7 //栈的结构定义 8 #define OK 1 9 #define ERROR 010 #define TRUE 111 #define FALSE 012 #define MAXSIZE 513 typedef int sElemType;14 typedef int Status;15 typedef struct16 {17 sElemType data[MAXSIZE];18 int top.. 阅读全文
posted @ 2014-02-08 16:06 CrazyCode. 阅读(657) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 using namespace std; 5 6 //一系列状态 7 #define OK 1 8 #define ERROR 0 9 #define TRUE 1 10 #define FALSE 0 11 typedef int Status; 12 13 //线性表的顺序存储 14 #define MAXSIZE 20 15 typedef int ElemType; 16 typedef struct 17 { 18 ElemType data[MAXSIZE... 阅读全文
posted @ 2014-02-08 14:53 CrazyCode. 阅读(251) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页