C语言 散列表 分离链接法 运行结果正确怎么说呢,散列表最重要的还是怎么设计散列函数,解决冲突还是很简单的完整代码#include<stdio.h>#include<malloc.h>#include<stdlib.h> //定义链表 typedef struct list_node *list_point ; struct list_node{ int val; list_point next; }; //定义散列表 typedef struct table_nod
C语言 桶排序 运行结果正确完整代码#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>void simple_bucket_sort(int arr[],int n,int max);void tra_arr(int arr[],int n);int main(){ int arr[10]={ 10,9,9,9,5,5,5,1,1,1 }; simple
C语言 基数排序 运行结果正确完整代码(审核中)主要代码#include"队列声明.h"void tra_arr(int arr[],int n);void get_pos_value(int in,int pos,int &result);void base_sort(int arr[],int n,int pos_num);int main(){ int arr[10]={ 999,888,777,66,55,44,3,2,1,33 }; base_sort(arr,10,3);
C语言 所有排序方法的实现 运行结果正确还是快速排序难一些。完整代码#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>void swap(int *a,int *b);void select_sort(int arr[],int n);void tra_arr(int arr[],int n);void insert_sort(int arr[],int n); voi
C语言 关键路径计算 运行结果正确完整代码还在审核主要代码#include"邻接表声明.h"#include"队列声明.h"#include"栈的声明.h"//统计入度void count_degree(adj_g_point g,int degree[]){ //初始化数组 for(int i=0;i<g->v_num;i++){ degree[i]=0; } //开始统计 adj_e_point e; int j; for(int i=0;i<g->v_num;i
C语言 拓扑排序 邻接表实现 运行结果正确完整代码 还在审核主要代码#include"邻接表声明.h"#include"队列声明.h"//拓扑排序void top_sort(adj_g_point g,int result[]){ //首先找一个数组把入度存一下 int *in_degree=(int*)malloc((g->v_num)*sizeof(int)); //初始化这个入度表 for(int i=0;i<g->v_num;i++){ in_degree[i]=0;
C语言 最小生成树 prim算法 运行结果正确主程序#include"矩阵声明.h"#include"邻接表声明.h"//在没访问过的顶点中找到与当前树距离最近的顶点void find_min(mat_g_point g,int dist[],int &min_id){ //首先给一个最大值去比较 int min=1000; //对每个顶点进行遍历 for(int i=0;i<g->nv;i++){ //如果没访问过,且权值比当前还要小 if(dist[i]!=0&&dist[
C语言 多源最短路径 邻接矩阵 运行结果正确输出路径顶点竟然花了我最多的时间。。。。。。#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>//邻接矩阵表示图typedef struct g_node *g_point;struct g_node{ int ne;//边数 int nv;//节点数 int arr[100][100]; int data[100];};
C语言 单源最短路径 有权 邻接矩阵 运行结果正确注意初始化的时候对path的特殊处理#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>//邻接矩阵表示图typedef struct g_node *g_point;struct g_node{ int ne;//边数 int nv;//节点数 int arr[100][100]; int data[100];};//边
C语言 完全二叉搜索树 运行结果正确其实计算树高那个地方我不是很懂为什么要/log(2)。#include <stdio.h>#include <stdlib.h>#include <math.h>//求左子树的节点数void left_tree_total(int n,int &total){ //首先,算一下完美二叉树的树高 int h=(int)floor(log(n+1)/log(2)); //计算完全二叉树的最后一层的叶子节点数 int x=n-pow(
C语言 前序和中序遍历确定后序遍历 运行结果正确还是很讨厌递归#include <stdio.h>#include <stdlib.h>int pre[100];//先序遍历数组 int in[100];//中序遍历 数组 int post[100]={0};//后序遍历数组 //后序遍历结果void tra_post(int total){ for(int i=0;i<total;i++){ printf("%d ",post[i]); } printf("");} //由先
C语言 深度优先搜索 非递归 运行结果正确注意,实际上栈里面存的是经过的节点#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>//创建邻接表//这个边的数据结构是用来给我们输入使用的typedef struct se_node *se_point;struct se_node{ int v1,v2; int weight;} ;//创建邻接表的边 typedef s
C语言 邻接表 广度优先搜索 非递归 运行结果正确非递归虽然实现起来比较复杂,但是容易纠错,也更好理解#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>//创建邻接表//这个边的数据结构是用来给我们输入使用的typedef struct se_node *se_point;struct se_node{ int v1,v2; int weight;} ;//创建邻接表的边
C语言 邻接表表示无向图 运行结果正确用邻接表来表示图要创造的结构体太多了,我感觉其实有更简单的结构体来表示图。#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>//创建邻接表//这个边的数据结构是用来给我们输入使用的typedef struct se_node *se_point;struct se_node{ int v1,v2; int weight;} ;
C语言 邻接矩阵表示无向图 运行结果正确#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>//邻接矩阵表示图typedef struct g_node *g_point;struct g_node{ int ne;//边数 int nv;//节点数 int arr[100][100]; int data[100];};//边的数据结构typedef struc
c语言 集合 按秩归并 压缩路径 运行结果正确感觉比二叉树还简单#include<stdio.h>#include <stdlib.h>#include <string.h>#include<malloc.h>//先定义一个栈 typedef struct Stack{ int base[100]; int top; }stack,*stack_point; //初始化一个集合的数组,数组的下标就是集合的元素,数组的值就是这个元素的父节点 void