1. 函数可以返回多个值 return a, b, c; 但是如果函数不是作为表达式的最后一个元素的话,仅返回第一个
如:
function f2() return "a", "b" end;
x, y = f2() -> x = "a", y = "b";
x, y = f2(), 1 -> x = "a", y = nil;
2. 可以将一个函数调用放入一对圆括...
分类:
其他好文 时间:
2014-05-10 09:21:56
阅读次数:
317
function FactoryXMLHttpRequest() {
if(window.XMLHttpRequest) {
return new XMLHttpRequest();
}else if(window.ActiveXObject) {
var msxmls = new Array(
'Msxml2.XM...
分类:
其他好文 时间:
2014-05-07 07:00:03
阅读次数:
382
9.2 构造方法
python 中也属于自己的构造函数和析构函数,
class fibs:
def __init__(self):
self.a = 0
self.b = 1
def next(self):
self.a,self.b = self.b,self.a+self.b
return self.a
def __iter__(self):
return sel...
分类:
编程语言 时间:
2014-05-07 05:51:56
阅读次数:
500
一、移动算法
其实2048的移动算法蛮简单,看代码很容易明白,就不多说了。
向左滑动
//左滑动
bool GameScene:: doLeft ()
{
//判断有没有发生移动
bool isMove = false ;
for ( int y = 0 ; y < 4; y++)
{...
分类:
移动开发 时间:
2014-05-07 05:51:22
阅读次数:
735
[Question]
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to t...
分类:
其他好文 时间:
2014-05-07 05:37:44
阅读次数:
278
转载请注明 本文出自:http://blog.csdn.net/nancle
首先说==和===
首先说明一个很特殊的值NaN, typeof(Nav)得到'number',但是NaN不等于任何一个值(包括它本身),判断一个值是不是NaN只能使用isNaNNaN == NaN //得到 false
NaN === NaN //得到false
isNaN(NaN) //得到true
然...
分类:
编程语言 时间:
2014-05-07 03:58:30
阅读次数:
363
题目
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recursiv...
分类:
其他好文 时间:
2014-05-07 03:30:19
阅读次数:
254
#include
using namespace std;
//汉罗塔递归求解函数 从a移到c
void move(int m,char a,char c);
void hanoi(int n,char a,char b,char c)
{
if(1==n)
{
move(n,a,c);
return;
}
hanoi(n-1,a,c,b);
move(n,a,c);
hano...
分类:
其他好文 时间:
2014-05-07 03:24:14
阅读次数:
228
五一中间断了几天,开始继续。。。
1、
??
Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a...
分类:
其他好文 时间:
2014-05-06 18:54:59
阅读次数:
386
#2.bool类型和const类型bool类型const限定符const与#define结构体内存对齐bool类型逻辑型也称布尔型,其取值为true(逻辑真)和false(逻辑假),存储字节数在不同编译系统中可能有所不同,VC++中为1个字节。声明方式:boolresult;result=true;可以当作整数用(true一般为1,fa..
分类:
其他好文 时间:
2014-05-06 16:25:36
阅读次数:
331