2011年4月14日

最大和子序列问题

摘要: // hhh.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>using namespace std;int MaxSub_Sum(const int A[ ], int N,int &seqStart, int&seqEnd){int thisSum ,MaxSum ,i , j;thisSum=0;MaxSum=0;i=0; /* 从左至右相加,若如结果是不断增加的,那么thisSum和MaxSum一起增加 若遇到负数,那么也加到ThisSum上去。此时ThisSum&l 阅读全文

posted @ 2011-04-14 21:11 IT@民工 阅读(169) 评论(0) 推荐(0) 编辑

N个元素数组中第K大元素

摘要: // K-key.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <time.h>#include <iostream>using namespace std;template <typename T>int pivotIndex(T arr[],int first,int last){ //随即产生一个pivotKey; srand((unsigned)time(NULL)); int temp=rand()%(last-first+1)+first; //把arr[temp]与arr 阅读全文

posted @ 2011-04-14 14:30 IT@民工 阅读(261) 评论(0) 推荐(0) 编辑

导航