>>> def power(x): ... return x*x ... >>> power(5) 25 >>> def power(x,n): ... s=1 ... while n >0: ... n = n -1 ... s = s*x ... return s ... >>> power(5,2) 25 >>> power(5,3) 125...
分类:
编程语言 时间:
2015-07-09 15:00:54
阅读次数:
162
题目:
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume
that each input would h...
分类:
编程语言 时间:
2015-07-09 14:40:16
阅读次数:
111
解法一:非递归 1 vector preorderTraversal(TreeNode* root) 2 { 3 vector res; 4 if (root == NULL) 5 return res; 6 7 stack node_stack; 8 ...
分类:
其他好文 时间:
2015-07-09 13:09:15
阅读次数:
103
Binary Tree Preorder Traversal 题目链接 题目要求: Given a binary tree, return thepreordertraversal of its nodes' values. For example: Given binary tree{1...
分类:
其他好文 时间:
2015-07-09 13:04:42
阅读次数:
91
引用的时候需要在参数和使用的时候加上 ref 关键字 static bool addnum (ref int val) //引用 { ++val; return true; }参数数组的概念,可以接受该类型的...
形参列表=>函数体函数体多于一条语句的可用大括号括起。类型可以将此表达式分配给委托类型,如下所示:delegate int del(int i);del myDelegate = x=>{return x*x;};int j = myDelegate(5);//j=25创建表达式目录树类型:usin...
Maximal SquareGiven a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the ...
分类:
其他好文 时间:
2015-07-09 12:41:13
阅读次数:
103
//给人定义一个功能,用来判断是否是同龄人;
class Person
{
private int age;
private String name;
Person(int age)
{
this.age=age;
}
public boolean compare(Person p)
{
return this.age==p.age;//!...
分类:
其他好文 时间:
2015-07-09 11:23:15
阅读次数:
106
题目:
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
解题:
递归的还是和前面中...
分类:
编程语言 时间:
2015-07-09 11:16:06
阅读次数:
179
1、修改数据库驱动phpcms/libs/classes/mysql.class.php添加以下代码:/***最近一次查询语句*/private$lastquerysql='';publicfunctionlastsql(){return$this->lastquerysql;}修改execute方...
分类:
数据库 时间:
2015-07-09 11:05:05
阅读次数:
161