
算法模板
daguge1
情不知所起,一往而深
展开
-
Fibonacci and 0-1背包
Fibonacci的快速幂求法时间是O(lgn)[cpp] view plaincopyprint?#include #include using namespace std; typedef unsigned long long int LINT; //函数 Fibonacci采用快速的幂的方法可以实现快速的 Fib转载 2015-04-29 09:58:13 · 287 阅读 · 0 评论 -
quick sort 快速排序
先上一个能用的代码[cpp] view plaincopy#include void swap(int a[], int i, int j) { int tmp=a[i]; a[i] = a[j]; a[j] = tmp; } int partition(in转载 2015-04-29 22:40:41 · 447 阅读 · 0 评论 -
selection sort 选择排序
先把代码贴出来,然后按照代码一步一步分析[cpp] view plaincopy#include void swap(int a[], int x, int y) { int tmp = a[x]; a[x] = a[y]; a[y] = tmp; }转载 2015-04-29 22:40:46 · 350 阅读 · 0 评论 -
Dijkstra算法
采用BFS搜索,因为bfs比dfs有微弱优势#include <iostream>#include<vector>#include<queue>#include<cstring>using namespace std; const int maxn=1000+10;/* run this program using the console pauser or add your own g原创 2015-05-15 09:48:11 · 324 阅读 · 0 评论 -
增广路 EdmondsKarp算法
最大流问题中求解 可以当做模板直接使用#include <iostream>#include<vector>#include<queue>#include<cstring>using namespace std; const int maxn=1000+10;/* run this program using the console pauser or add your own get原创 2015-05-15 09:40:06 · 426 阅读 · 0 评论 -
无根树有根树转化
算法如下,采取DFS遍历#include <iostream>#include<vector>#include<cstring>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */int p[100];/原创 2015-05-15 09:43:57 · 560 阅读 · 0 评论 -
二维平面几何
二维平面几何中关于向量运算的实现#include <iostream>#include<cmath>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */struct point{ double x,y原创 2015-06-11 09:30:43 · 391 阅读 · 0 评论 -
BP网络范例 MATLAB
clcclearcd C:\Users\ASUS1\DesktopA=xlsread('第二题数据.xls');p=A(:,1:4)';t=A(:,5)';[pn,minp,maxp,tn,mint,maxt]=premnmx(p,t);%原始数据归一化?net=newff(pn,tn,[9],{'tansig','purelin'},'traingdx');%设置网络,建立相应的BP原创 2015-07-17 14:03:23 · 454 阅读 · 0 评论 -
图的连通性判断
判断图的连通性,程序目的是为了检验一个网络是否为联通的,如果不连通,会将小的区块的节点号报出。#include <iostream>#include <cstdio>#include <vector>#include<fstream>#include<string>#include<iomanip>using namespace std;const int maxn = 1000 + 5原创 2017-08-03 10:37:19 · 1671 阅读 · 0 评论