一)函数A)JS中的函数的定义格式:functionadd(a,b){varsum=a+b;document.write("两个数的和是:"+sum);//returnsum;}上面只是一个例子,那么当我们再定义一个同名的函数会怎么样呢?functionadd(a,b,c){varsum=a+b+c...
分类:
Web程序 时间:
2014-11-17 12:15:34
阅读次数:
286
在使用servlet输出中,使用如下代码response设置输出格式无效,发现怎么改都是乱码。 PrintWriter?out?=?response.getWriter();
response.setContentType("text/html;charset=GB2312"); ?后来发现,设置格式...
分类:
其他好文 时间:
2014-11-16 20:17:15
阅读次数:
221
innodb的脏数据刷入到硬盘是靠专门的进程负责,页是硬盘读写的最小单位,innodb自己也有类似的管理理念,硬盘默认的一般为512K,当然也可以在挂载系统时设置,对于INNODB来讲,其页大小为16K。那么问题来了,假如缓冲池中的一个页从内存刷新到硬盘时,假如刚写了100b就意外断电..
分类:
数据库 时间:
2014-11-16 18:50:25
阅读次数:
216
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"思路分析:...
分类:
其他好文 时间:
2014-11-16 10:44:42
阅读次数:
164
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to...
分类:
其他好文 时间:
2014-11-16 08:12:43
阅读次数:
145
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
分类:
其他好文 时间:
2014-11-15 18:47:58
阅读次数:
103
记得以前就看过这篇文章:How to write a spelling corrector,文章将贝叶斯原理运用于拼写检查,二十几行简单的Python的代码就实现了一个拼写检查器。感叹数学的美妙之外,也很喜欢类似这样的文章,将一个问题的原理讲清楚,再配上一些代码实例做说明,从小见大,从浅入深,对人很...
分类:
其他好文 时间:
2014-11-15 18:18:13
阅读次数:
233
文件方法
读写:
#!/usr/bin/env python
f = open('somefile.txt','w')
f.write('Hello,')
f.write('World!')
f.close()
f = open('somefile.txt','r')
print f.read(5)Hello使用基本文件方法:
#!/usr/bin/env python
f = open(r...
分类:
编程语言 时间:
2014-11-15 15:32:37
阅读次数:
218
importsysimportpymongofrompymongoimportConnectionfrompymongo.errorsimportConnectionFailuredefmain():try:conn=Connection(host="localhost",port=27017)exceptConnectionFailure,e:sys.stderr.write("connectionfailure:%s"%e)sys.exit(1)db=conn["books"]book_doc={"ISD..
分类:
其他好文 时间:
2014-11-15 11:34:47
阅读次数:
171
Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally ide...
分类:
其他好文 时间:
2014-11-15 11:13:11
阅读次数:
171