随笔分类 - 数据结构
1
主要以C++描述为主吧
摘要:1 //基于邻接表 2 struct vertexnode 3 { 4 int vertex; 5 edgenode * firstedge; 6 }; 7 struct edgenode 8 { 9 int adjvex; 10 edgenode *next; 11 }; 12 struct ve
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 //除基取余倒排序 4 void zhuan(int num,int r) 5 { 6 int top = -1, s[1000],k; 7 while (num!=0) 8 { 9 k = num % r
阅读全文
摘要:1 #include <iostream> 2 #include <queue> 3 using namespace std; 4 typedef struct node 5 { 6 struct node *left, *right; 7 char data; 8 9 }BiTreeNode, *
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 4 const int MaxSize = 10; //图中最多顶点个数 5 int visited[MaxSize] = { 0 }; //全局数组变量visited初始化 6 7 class MGrap
阅读全文
摘要:1 //约瑟夫环 2 #include <iostream> 3 using namespace std; 4 struct list 5 { 6 int number; 7 list *next; 8 }; 9 int main() 10 { 11 list *head, *s, *p, *q;
阅读全文
摘要:1 //折半查找 2 #include<iostream> 3 #include <algorithm> 4 using namespace std; 5 int zheban(int a[], int n, int k) 6 { 7 int low = 1, high = n - 1, mid;
阅读全文
摘要:1 //冒泡排序 2 #include<iostream> 3 #include <algorithm> 4 using namespace std; 5 void bubblesort(int a[], int size) 6 { 7 int i, j; 8 for (i = 0; i < siz
阅读全文
摘要:1 //选择排序 2 #include<iostream> 3 #include <algorithm> 4 using namespace std; 5 void selectsort(int a[], int size) 6 { 7 int pos, min, j; 8 for (pos=0;p
阅读全文
摘要:1 //希尔排序 2 #include <iostream> 3 #include <algorithm> 4 using namespace std; 5 void ShellSort(int a[], int n) 6 { 7 int gap, pos, j; 8 int tmp; 9 for
阅读全文
摘要:1 //堆排序 2 #include <iostream> 3 #include <algorithm> 4 using namespace std; 5 void duipai1(int a[], int pos, int size) 6 { 7 int child; 8 int tmp = a[
阅读全文
摘要:1 //快速排序 2 #include<iostream> 3 #include <algorithm> 4 using namespace std; 5 int kuaipai1(int r[], int first, int end) 6 { 7 int i = first; 8 int j =
阅读全文
摘要:1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 class Matcher{ 6 public: 7 Matcher(string str); 8 ~Matcher(){ }; 9 int match(); 1
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 typedef struct node 4 { 5 struct node *left, *right; 6 char data; 7 8 }BiTreeNode,*BiTree; 9 void creat
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 int BF(char S[], char T[]); 4 int main() 5 { 6 char s1[100], s2[10]; 7 int index = 0; 8 cout << "请输入主串:
阅读全文
摘要:1 //顺序栈 2 #include <iostream> 3 using namespace std; 4 const int StackSize = 5; 5 class SeqStack 6 { 7 public: 8 SeqStack(); 9 ~SeqStack(); 10 void Pu
阅读全文
摘要:1 //C++实现链队 2 #include <iostream> 3 using namespace std; 4 struct Node 5 { 6 int data; 7 Node *next; 8 }; 9 class LinkQueue 10 { 11 public: 12 LinkQue
阅读全文
摘要:1 //链栈C++描述 2 #include <iostream> 3 using namespace std; 4 5 struct Node 6 { 7 int data; //数据域 8 Node *next; //指针域 9 }; 10 11 12 class LinkStack 13 {
阅读全文
摘要:1 //c语言单链表 2 #include <stdio.h> 3 #include <stdlib.h> 4 typedef struct Node 5 { 6 int data;//数据域 7 struct Node *pNext;//指针域 8 }NODE,*PNODE;////NODE等价于
阅读全文
摘要:1 #include <iostream> //引入输入输出流 2 using namespace std; 3 4 struct Node 5 { 6 int data; //数据域 7 Node *next; //指针域 8 }; 9 10 class LinkList 11 { 12 publ
阅读全文
摘要:1 #include<iostream> 2 using namespace std; 3 const int MaxSize = 100; 4 class SeqList 5 { 6 public: 7 SeqList(); 8 SeqList(int a[], int n); 9 ~SeqLis
阅读全文
1