![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法课
文章平均质量分 54
niyayu
这个作者很懒,什么都没留下…
展开
-
最大子段和问题(O(N^3))
#include int a[1000]; void nCompareNum(int n) { int i,j,k,Max=0,sum,NumFrom=0,NumTo=0; for(i=0;i原创 2011-09-08 14:45:41 · 135 阅读 · 0 评论 -
prime
#include using namespace std; #define MAX 101 #define INF 99999999 struct stuNodes { int nFrom; int nCost; int nTo; }; void vInput(int nArry[][MAX],int nN); int nGetMin(int nArry...原创 2011-12-01 20:09:09 · 115 阅读 · 0 评论 -
哈弗曼编码
#include #define MAX 1001 #define INF 999999 struct stuNode { int nLeftTree; int nRightTree; int nPd; }; struct stuNo12 { int No1; int No2; }; void vInput(int nArr[], int nN...原创 2011-11-28 10:42:49 · 124 阅读 · 0 评论 -
最大子段和
给出N个数字, 计算出最大的子段和。 Input 第一行给出一个数字 T(1原创 2012-01-05 13:59:27 · 203 阅读 · 0 评论 -
最长不下降子序列长度
对于序列(1, 7, 3, 5, 9, 4, 8),有它的一些不下降子序列 如(1, 7), (3, 4, 8)等等。这些子序列中最长的长度是4,比如子序列(1, 3, 5, 8)。 Input 多组cas , 每组cas 两行: 第一行 输入一个数 n (n < 10000), 表示有n个数 第二行 n个数, 分别代表每个数; Output 每个cas 一行 ...原创 2012-01-05 13:55:33 · 345 阅读 · 0 评论 -
求两字符串匹配的最长子序列
如果两种特征序列的[color=red]公共子序列[/color]越长表示越接近,现在请你帮助计算出最长的公共特征。 输入说明: 本问题有多组测试数据,第一行就是测试数据的组数(1>sY; sX=" "+sX; sY=" "+sY; nX=sX.size()-1; nY=sY.size()-1; ...原创 2012-01-05 13:52:20 · 298 阅读 · 0 评论 -
编辑距离问题
#include #include using namespace std; #define MAX 1001 int nEditD[MAX][MAX]; void vInit(int nA,int nB); void vGetEdit(string sA,string sB,int nA,int nB); void vOut(int nA,int nB...原创 2012-01-05 13:48:47 · 86 阅读 · 0 评论 -
#贪心算法(零件加工)
#include #include #include using namespace std; #define MAX 1001 struct strTime { int nStart; int nEnd; }; strTime strLing[MAX],strMach[MAX]; void vInit(); void vInput(int n); void...原创 2011-10-27 13:25:47 · 661 阅读 · 0 评论 -
众数问题
#include #include using namespace std ; int main() { int min,max ; int n; int inta[100000] ; int i; while(scanf("%d",&n)!=EOF) { min=1000000000; max=0; memset(inta,0,si...原创 2011-10-20 14:57:49 · 260 阅读 · 0 评论 -
输油管道问题
#include #include #include #define MAX 100000 void ps(int a[],int low,int high) //快速排序 { int key,i,j; i=low; j=high; key=a[low]; if(low>high...原创 2011-10-13 14:45:55 · 106 阅读 · 0 评论 -
幂的精确求值
#include using namespace std; #define MAX 4001 int nGetPow(int num,int pow); int main() { int num,pow; while(cin >>num >>pow) { nGetPow(num,pow); } return 0; } int nGetPo...原创 2011-09-22 15:07:59 · 181 阅读 · 0 评论 -
大数加法
#include #include using namespace std; string nGetstrAB(string strA,string strB); void vOutPut(string strRet); int main() { string strA,strB,strAB; while(cin >>strA >>strB) {...原创 2011-09-22 12:56:21 · 117 阅读 · 0 评论 -
三姐妹之出题
#include #include using namespace std; struct stuOneF { int nFact; int nPow; }; struct stuAllFs { int nFact[50]; int nPow[50]; int nCount; }; stuAllF...原创 2011-09-15 14:15:21 · 277 阅读 · 0 评论 -
最大子段和问题(分治)(##)
#include #define MAX 100001 struct str { int nFrom; int nTo; int nSum; }; str getMax(int nData[],int n); void vPutOut(str A); str get3Parts(int nData[],int left,int right); str get...原创 2011-09-08 21:31:53 · 184 阅读 · 0 评论 -
最大子段和问题(O(N^2))
#include int a[10000]; void nCompareNum(int n) { int i,j,Max=0,sum,NumFrom=0,NumTo=0; for(i=0;i原创 2011-09-08 15:04:20 · 112 阅读 · 0 评论 -
Kruskal最小生成树
#include #include using namespace std; #define MAX 101 struct stuEdge { int nFrom; int nCost; int nTo; }; int nInput(stuEdge stuArr[],int nN); void vSort(int nEdge,stuEdge stuArr...原创 2011-12-08 14:26:12 · 88 阅读 · 0 评论