摘要: 使用邻接矩阵存储加权图,无穷大使用常数MAXLEN代表,然后使用Dijkstra方法求取最短路径 1 #include <stdio.h> 2 3 #define MAXLEN 1000 4 int cost[7][7]; 5 int dist[7]; 6 7 void creategraph(in 阅读全文
posted @ 2021-01-02 22:21 互联星空 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 图的深度优先搜索 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct node 5 { 6 int vertex; 7 struct node* nextnode; 8 }; 9 10 typedef struct node* graph; 1 阅读全文
posted @ 2021-01-02 15:24 互联星空 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 使用数组导入边创建邻接矩阵表示法的图 1 #include <stdio.h> 2 3 int matrix[6][6]; 4 5 void creategraph(int *node,int num) 6 { 7 int from; 8 int to; 9 int i; 10 11 for(i = 阅读全文
posted @ 2021-01-02 01:21 互联星空 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 使用递归方式创建二叉树,然后备份原来的二叉树,最后将原来的二叉树和备份的二叉树都输出来 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct tree 5 { 6 int data; 7 struct tree* left; 8 struct t 阅读全文
posted @ 2021-01-01 18:40 互联星空 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 二叉树的递归创建 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct tree 5 { 6 int data; 7 struct tree* left; 8 struct tree* right; 9 }; 10 11 typedef stru 阅读全文
posted @ 2021-01-01 15:57 互联星空 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 中序遍历 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct tree 5 { 6 int data; 7 struct tree* left; 8 struct tree* right; 9 }; 10 11 typedef struct t 阅读全文
posted @ 2021-01-01 15:25 互联星空 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 二叉树的数组表示 1 #include <stdio.h> 2 3 void createbtree(int * btree,int *data,int len) 4 { 5 int level; 6 int i; 7 8 btree[1] = data[1]; 9 for(i = 2; i <= 阅读全文
posted @ 2021-01-01 14:51 互联星空 阅读(657) 评论(0) 推荐(0) 编辑
摘要: 使用数组创建队列 1 #include <stdio.h> 2 #define MAXQUEUE 10 3 4 int queue[MAXQUEUE]; 5 int front = -1; 6 int rear = -1; 7 8 int enqueue(int value) 9 { 10 if(r 阅读全文
posted @ 2020-12-31 19:48 互联星空 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 线性探测法 1 //使用线性探测法和数组结构创建散列表, 2 //然后输入数据的查询。并且将创建过程 3 //都输出来 4 #include <stdlib.h> 5 #include <stdio.h> 6 #include <time.h> 7 #define MAX 10 //最大数组容量 8 阅读全文
posted @ 2020-12-30 15:48 互联星空 阅读(541) 评论(0) 推荐(0) 编辑
摘要: 1中序表达式求值 1 //计算中序四则表达式的值,输入的表达式内的每一个字符 2 //代表一个操作数或运算符,而且中间不可有空格,换句话 3 //说,操作数的范围只有数字0到9 4 #include <stdlib.h> 5 #include <stdio.h> 6 7 struct stack_n 阅读全文
posted @ 2020-12-29 19:03 互联星空 阅读(274) 评论(0) 推荐(0) 编辑