
算法类
。。。
努 力 小 子
憨憨一个
展开
-
使用分支限界法解决单源最短路径问题。
#include<iostream> #include<cstdio> #include<queue> using namespace std; typedef struct ArcCell{ int weight;//保存权值 weight=1说明一开始就输入了这条边,=0说明这两个点之间没有边 int min_length;//存储最短路径长度 }ArcCell,AdjMaxtrix[100][100]; typedef struct{原创 2020-05-30 11:19:31 · 14420 阅读 · 7 评论 -
01背包问题回溯法
#include<iostream> #include<cstring> using namespace std; int n; double c; double v[100]; double w[100]; double cw = 0.0; double cv = 0.0; double MAX_put = 0.0; double ratio[100];//比率 int order[100]; int put[100]; void knapsack()//按比值进行排序原创 2020-05-21 20:26:38 · 867 阅读 · 0 评论 -
使用贪心算法解决最小生成树问题。
使用贪心算法解决最小生成树问题。 #include<iostream> #include<algorithm> using namespace std; const int MAX=100; const int MAX_length=10000; int n,m; int G[MAX][MAX];//相邻两边的长 int d[MAX]; bool V[MAX]={false}; int prim(){ int sum=0; V[1]=true; d[1]=0; for(i原创 2020-05-21 15:54:26 · 2649 阅读 · 0 评论