摘要:
闭包(closure)是Javascript语言的一个难点,也是它的特色,很多高级应用都要依靠闭包实现。一、变量的作用域要理解闭包,首先必须理解Javascript特殊的变量作用域。变量的作用域无非就是两种:全局变量和局部变量。Javascript语言的特殊之处,就在于函数内部可以直接读取全局变量。Js代码 var n=999; function f1(){ alert(n); } f1();// 999另一方面,在函数外部自然无法读取函数内的局部变量。Js代码 function f1(){ var n=999; } alert(n);// error这里有一个地方需... 阅读全文
摘要:
1023. Have Fun with Numbers (20)Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a different permuta 阅读全文
摘要:
最近在刷PAT题,将自己的解题过程和代码写在blog上。Tree Traversals (25)时间限制400 ms内存限制32000 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of.. 阅读全文