This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
void Candy(int weight[], vector<int>& result, int len) | |
{ | |
int i = 0; | |
while (i < len) { | |
int j; | |
int count = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void FindNumOnce(int pArray[], int nLength, | |
int* pNum1, int* pNum2); | |
int FindFirstBit1(int nNum); | |
bool IsBit1(int nNum, int nPos); | |
void FindNumOnce(int pArray[], int nLength, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://www.ahathinking.com/archives/124.html | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
int LCS(const string& str1, const string& str2, string& longest_seq) | |
{ | |
int len1 = str1.size(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//来自《数据结构与算法分析——C语言描述》,Mark Allen Weiss,第7章,排序 | |
//todo: 桶排序 | |
#include <iostream> | |
using namespace std; | |
typedef int ElementType; | |
static const int QS_CUT_OFF = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <ctime> | |
using namespace std; | |
//dim==10000------1.406s | |
//最直接的方法 | |
void transpose1(int* dst, int* src, int dim) | |
{ | |
int i, j; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//寻找前K大的数的几种解法 | |
//来自《编程之美》2.5 | |
#include <iostream> | |
#include <limits> | |
#include <cstdlib> | |
using namespace std; | |
//解法一,排序 | |
void Method1(float array[], int len, int K); |