#include
double fun(double q)
{
int n=2;
double s=2.0;
while(s<=q)
{
s=s+(double)(n+1)/n;
n++;
}
return s;
}
main()
{
printf("%f\n",fun(50));
}...
分类:
其他好文 时间:
2014-07-22 22:38:36
阅读次数:
136
动态分配的vector指针
vector *get_num(int n)
{
vector *pv = new vector(n+1);
int i , x;
for(i = 0; i >x;
(*pv)[i] = (x);
}
return pv;
}
如果是动态分配的vector...
分类:
其他好文 时间:
2014-07-22 22:38:16
阅读次数:
256
CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3.....
分类:
其他好文 时间:
2014-07-22 22:36:54
阅读次数:
153
如:class cls{ public: void print(int i){printf(i);};}int main(){ std::map mymap; return 0;}这段程序是否有问题?上面的cls作为Key来说需要满足1. 支持 < 运算符,或者给定了<判断式,map内部是红...
分类:
其他好文 时间:
2014-07-22 22:35:54
阅读次数:
203
Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o...
分类:
其他好文 时间:
2014-07-22 22:35:53
阅读次数:
230
/*replace有接受两个参数,第一个参数可以是字符串,也可以是正则表达式,第二个参数除支持字符串之外,还支持$1形式正则匹配的文本,除此之外还支持传入一个处理函数,这个函数的return值就是要替换成的内容。了解更多javascript的String.replace用法,访问:http://ww...
分类:
其他好文 时间:
2014-07-22 22:34:53
阅读次数:
204
//方案一: O(N)? 不适合海量数据int* maxK(int A[] , const int& n, const int& k){ if(np) --end; if(begin>=end) return begin; swap(A[begin],A[end]); ...
分类:
其他好文 时间:
2014-07-22 22:34:53
阅读次数:
140
一、题目POJ 1061 青蛙的约会【关于“欧几里得求最大公约数”和“扩展欧几里得算法”的题目】二、题目源程序#include using namespace std;#define LL long longLL gcd(LL a, LL b){ return b ? gcd(b, a%b)...
分类:
其他好文 时间:
2014-07-22 22:34:36
阅读次数:
253
// 基类
var BaseCalculator = function(){
this.decimalDigits = 2;
};
// public
BaseCalculator.prototype.add = function(x, y) {
return x + y;
}
// public
BaseCalculator.prototype.subtract = function(x...
分类:
编程语言 时间:
2014-07-22 22:33:55
阅读次数:
180
import re
def validateEmail(email):
if len(email) > 7:
if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) != None:
return 1
r...
分类:
编程语言 时间:
2014-07-22 17:40:41
阅读次数:
881