![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
文章平均质量分 68
sunnyyouknow
这个作者很懒,什么都没留下…
展开
-
find the N max numbers from an array
//find the N max numbers from an array #include using namespace std; void swap(int &a, int &b) { int tmp = a; a = b; b = tmp; } int partition(int *data, int beg, int end) { int pos原创 2013-08-07 14:12:31 · 415 阅读 · 0 评论 -
compute the max sum of a continuours subset
#include #include using namespace std; int partition(int *data, int beg, int end) { int mid = beg + (end-beg)/2; if(beg > end) return 0; else if(beg == end) return data原创 2013-08-06 12:20:51 · 463 阅读 · 0 评论 -
compute the max sum of a continuours subset
// compute the max sum of a continuours subset #include #include using namespace std; int maxMultiply(int *data, int beg, int end) { int minRes, maxRes, res; minRes = maxRes = r原创 2013-08-06 15:15:17 · 608 阅读 · 0 评论 -
implement of power(double base, int expo), without using math library.
#include #include #include using namespace std; #define MIN 1e-6 bool equal(double a, double b) { if(fabs(a-b) < MIN) return true; return false; } #if 0 double myPower(double ba原创 2013-08-06 21:31:29 · 527 阅读 · 0 评论 -
implementation of string class
#include #include using namespace std; class myString { public: //myString(); myString(const char *str = NULL); myString(const myString &other); myString& operator=(const myString原创 2013-08-06 10:51:50 · 516 阅读 · 0 评论 -
print the numbers less than the max n-bit integer
#include #include #include #include #include using namespace std; void print1ToNDigits(char *buf, int beg, int len) { if(beg == len-1) { cout << buf << endl; return;原创 2013-08-06 01:30:38 · 480 阅读 · 0 评论 -
String permutation
#include #include #include using namespace std; void Permutation(char *str, char *beg) { if(*beg == '\0') cout << str <<endl; else { for(char *tmp = beg; *tmp != '\0'; tmp++) {原创 2013-08-05 14:05:57 · 628 阅读 · 0 评论 -
String combination
#include #include #include #include #include using namespace std; #if 0 void combination(const char *str, int m, vector &res) { if(*str == '\0' && m != 0) return; if(m == 0)原创 2013-08-05 17:39:05 · 488 阅读 · 0 评论 -
calculate the distance of two string
#include #include #include using namespace std; #define MIN(x, y, z) ((x < y) ? (x < z ? x : z) : (y < z ? y : z)) int calcStringDistance(const string &s1, int beg1, int end1, const string &s2,原创 2013-08-04 15:12:37 · 407 阅读 · 0 评论 -
count the number of 1 in a decimal integer
#include using namespace std; long count1sOfInteger(int num) { long res = 0; int factor = 1; long high, cur, low; while(num / factor) { low = num - (num/factor)*factor;原创 2013-08-07 12:00:49 · 533 阅读 · 0 评论