码迷,mamicode.com
首页 >  
搜索关键字:return    ( 60766个结果
为JS字符类型添加trim方法
JS字符串本身并不没有提供常用的trim方法,我们可以通过修改String原形来添加此方法,我们就可以直接调用此方法了: String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, '')}String.proto...
分类:Web程序   时间:2014-07-01 20:25:50    阅读次数:242
js产生随机数
方法一:产生0~n之间的一个随机数function getRandom(n) {return Math.floor(Math.random() * n);}alert(getRandom(10)); 方法二:产生自定义的Min~Max之间的一个随机数function GetRandomNum(Min...
分类:Web程序   时间:2014-07-01 19:34:00    阅读次数:241
a href=#与 a href=javascript:void(0) 的差别
a href="#"> 点击链接后,页面会向上滚到页首,# 默认锚点为 #TOP 点击链接后,页面不动,仅仅打开链接 作用同上,不同浏览器会有差异。点击链接后,不想使页面滚到页首,就用href="javascript:void(0)",不要用href="#",return false也有相似作用具体...
分类:编程语言   时间:2014-07-01 13:41:35    阅读次数:272
Leetcode:First Missing Positive 第一个缺失的正数 桶排序
First Missing Positive:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] retu...
分类:其他好文   时间:2014-07-01 13:13:59    阅读次数:218
LeetCode:Combinations 题解
Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],...
分类:其他好文   时间:2014-07-01 13:01:01    阅读次数:177
Leetcode:Combinations 生成组合
Combinations:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ ...
分类:其他好文   时间:2014-07-01 12:58:20    阅读次数:212
leetcode 题解:Binary Tree Level Order Traversal (二叉树的层序遍历)
题目:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,...
分类:其他好文   时间:2014-07-01 12:44:09    阅读次数:199
优化后的二次测试Miller_Rabin素性测试算法
ll random(ll n){ return (ll)((double)rand()/RAND_MAX*n + 0.5);}ll pow_mod(ll a,ll p,ll n){ if(p == 0) return 1; ll ans = pow_mod(a,p/2...
分类:其他好文   时间:2014-07-01 12:29:43    阅读次数:218
leetcode题解:Tree Level Order Traversal II (二叉树的层序遍历 2)
题目:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For ...
分类:其他好文   时间:2014-07-01 12:26:07    阅读次数:215
大整数乘法 python实现
def recursive_multiply(x, y, n): if n==1: return x*y else: a = x/pow(10, n/2) b = x-a*pow(10, n/2) c = y/pow(10, n/2) d = y-c*pow(10, n/2) ac = re...
分类:编程语言   时间:2014-07-01 12:20:43    阅读次数:273
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!